##// END OF EJS Templates
resolve: simplify "finished" message...
Matt Mackall -
r21267:e4f451c8 default
parent child Browse files
Show More
@@ -1,5947 +1,5946 b''
1 1 # commands.py - command processing for mercurial
2 2 #
3 3 # Copyright 2005-2007 Matt Mackall <mpm@selenic.com>
4 4 #
5 5 # This software may be used and distributed according to the terms of the
6 6 # GNU General Public License version 2 or any later version.
7 7
8 8 from node import hex, bin, nullid, nullrev, short
9 9 from lock import release
10 10 from i18n import _
11 11 import os, re, difflib, time, tempfile, errno
12 12 import sys
13 13 import hg, scmutil, util, revlog, copies, error, bookmarks
14 14 import patch, help, encoding, templatekw, discovery
15 15 import archival, changegroup, cmdutil, hbisect
16 16 import sshserver, hgweb, commandserver
17 17 from hgweb import server as hgweb_server
18 18 import merge as mergemod
19 19 import minirst, revset, fileset
20 20 import dagparser, context, simplemerge, graphmod
21 21 import random
22 22 import setdiscovery, treediscovery, dagutil, pvec, localrepo
23 23 import phases, obsolete, exchange
24 24
25 25 table = {}
26 26
27 27 command = cmdutil.command(table)
28 28
29 29 # common command options
30 30
31 31 globalopts = [
32 32 ('R', 'repository', '',
33 33 _('repository root directory or name of overlay bundle file'),
34 34 _('REPO')),
35 35 ('', 'cwd', '',
36 36 _('change working directory'), _('DIR')),
37 37 ('y', 'noninteractive', None,
38 38 _('do not prompt, automatically pick the first choice for all prompts')),
39 39 ('q', 'quiet', None, _('suppress output')),
40 40 ('v', 'verbose', None, _('enable additional output')),
41 41 ('', 'config', [],
42 42 _('set/override config option (use \'section.name=value\')'),
43 43 _('CONFIG')),
44 44 ('', 'debug', None, _('enable debugging output')),
45 45 ('', 'debugger', None, _('start debugger')),
46 46 ('', 'encoding', encoding.encoding, _('set the charset encoding'),
47 47 _('ENCODE')),
48 48 ('', 'encodingmode', encoding.encodingmode,
49 49 _('set the charset encoding mode'), _('MODE')),
50 50 ('', 'traceback', None, _('always print a traceback on exception')),
51 51 ('', 'time', None, _('time how long the command takes')),
52 52 ('', 'profile', None, _('print command execution profile')),
53 53 ('', 'version', None, _('output version information and exit')),
54 54 ('h', 'help', None, _('display help and exit')),
55 55 ('', 'hidden', False, _('consider hidden changesets')),
56 56 ]
57 57
58 58 dryrunopts = [('n', 'dry-run', None,
59 59 _('do not perform actions, just print output'))]
60 60
61 61 remoteopts = [
62 62 ('e', 'ssh', '',
63 63 _('specify ssh command to use'), _('CMD')),
64 64 ('', 'remotecmd', '',
65 65 _('specify hg command to run on the remote side'), _('CMD')),
66 66 ('', 'insecure', None,
67 67 _('do not verify server certificate (ignoring web.cacerts config)')),
68 68 ]
69 69
70 70 walkopts = [
71 71 ('I', 'include', [],
72 72 _('include names matching the given patterns'), _('PATTERN')),
73 73 ('X', 'exclude', [],
74 74 _('exclude names matching the given patterns'), _('PATTERN')),
75 75 ]
76 76
77 77 commitopts = [
78 78 ('m', 'message', '',
79 79 _('use text as commit message'), _('TEXT')),
80 80 ('l', 'logfile', '',
81 81 _('read commit message from file'), _('FILE')),
82 82 ]
83 83
84 84 commitopts2 = [
85 85 ('d', 'date', '',
86 86 _('record the specified date as commit date'), _('DATE')),
87 87 ('u', 'user', '',
88 88 _('record the specified user as committer'), _('USER')),
89 89 ]
90 90
91 91 templateopts = [
92 92 ('', 'style', '',
93 93 _('display using template map file (DEPRECATED)'), _('STYLE')),
94 94 ('T', 'template', '',
95 95 _('display with template'), _('TEMPLATE')),
96 96 ]
97 97
98 98 logopts = [
99 99 ('p', 'patch', None, _('show patch')),
100 100 ('g', 'git', None, _('use git extended diff format')),
101 101 ('l', 'limit', '',
102 102 _('limit number of changes displayed'), _('NUM')),
103 103 ('M', 'no-merges', None, _('do not show merges')),
104 104 ('', 'stat', None, _('output diffstat-style summary of changes')),
105 105 ('G', 'graph', None, _("show the revision DAG")),
106 106 ] + templateopts
107 107
108 108 diffopts = [
109 109 ('a', 'text', None, _('treat all files as text')),
110 110 ('g', 'git', None, _('use git extended diff format')),
111 111 ('', 'nodates', None, _('omit dates from diff headers'))
112 112 ]
113 113
114 114 diffwsopts = [
115 115 ('w', 'ignore-all-space', None,
116 116 _('ignore white space when comparing lines')),
117 117 ('b', 'ignore-space-change', None,
118 118 _('ignore changes in the amount of white space')),
119 119 ('B', 'ignore-blank-lines', None,
120 120 _('ignore changes whose lines are all blank')),
121 121 ]
122 122
123 123 diffopts2 = [
124 124 ('p', 'show-function', None, _('show which function each change is in')),
125 125 ('', 'reverse', None, _('produce a diff that undoes the changes')),
126 126 ] + diffwsopts + [
127 127 ('U', 'unified', '',
128 128 _('number of lines of context to show'), _('NUM')),
129 129 ('', 'stat', None, _('output diffstat-style summary of changes')),
130 130 ]
131 131
132 132 mergetoolopts = [
133 133 ('t', 'tool', '', _('specify merge tool')),
134 134 ]
135 135
136 136 similarityopts = [
137 137 ('s', 'similarity', '',
138 138 _('guess renamed files by similarity (0<=s<=100)'), _('SIMILARITY'))
139 139 ]
140 140
141 141 subrepoopts = [
142 142 ('S', 'subrepos', None,
143 143 _('recurse into subrepositories'))
144 144 ]
145 145
146 146 # Commands start here, listed alphabetically
147 147
148 148 @command('^add',
149 149 walkopts + subrepoopts + dryrunopts,
150 150 _('[OPTION]... [FILE]...'))
151 151 def add(ui, repo, *pats, **opts):
152 152 """add the specified files on the next commit
153 153
154 154 Schedule files to be version controlled and added to the
155 155 repository.
156 156
157 157 The files will be added to the repository at the next commit. To
158 158 undo an add before that, see :hg:`forget`.
159 159
160 160 If no names are given, add all files to the repository.
161 161
162 162 .. container:: verbose
163 163
164 164 An example showing how new (unknown) files are added
165 165 automatically by :hg:`add`::
166 166
167 167 $ ls
168 168 foo.c
169 169 $ hg status
170 170 ? foo.c
171 171 $ hg add
172 172 adding foo.c
173 173 $ hg status
174 174 A foo.c
175 175
176 176 Returns 0 if all files are successfully added.
177 177 """
178 178
179 179 m = scmutil.match(repo[None], pats, opts)
180 180 rejected = cmdutil.add(ui, repo, m, opts.get('dry_run'),
181 181 opts.get('subrepos'), prefix="", explicitonly=False)
182 182 return rejected and 1 or 0
183 183
184 184 @command('addremove',
185 185 similarityopts + walkopts + dryrunopts,
186 186 _('[OPTION]... [FILE]...'))
187 187 def addremove(ui, repo, *pats, **opts):
188 188 """add all new files, delete all missing files
189 189
190 190 Add all new files and remove all missing files from the
191 191 repository.
192 192
193 193 New files are ignored if they match any of the patterns in
194 194 ``.hgignore``. As with add, these changes take effect at the next
195 195 commit.
196 196
197 197 Use the -s/--similarity option to detect renamed files. This
198 198 option takes a percentage between 0 (disabled) and 100 (files must
199 199 be identical) as its parameter. With a parameter greater than 0,
200 200 this compares every removed file with every added file and records
201 201 those similar enough as renames. Detecting renamed files this way
202 202 can be expensive. After using this option, :hg:`status -C` can be
203 203 used to check which files were identified as moved or renamed. If
204 204 not specified, -s/--similarity defaults to 100 and only renames of
205 205 identical files are detected.
206 206
207 207 Returns 0 if all files are successfully added.
208 208 """
209 209 try:
210 210 sim = float(opts.get('similarity') or 100)
211 211 except ValueError:
212 212 raise util.Abort(_('similarity must be a number'))
213 213 if sim < 0 or sim > 100:
214 214 raise util.Abort(_('similarity must be between 0 and 100'))
215 215 return scmutil.addremove(repo, pats, opts, similarity=sim / 100.0)
216 216
217 217 @command('^annotate|blame',
218 218 [('r', 'rev', '', _('annotate the specified revision'), _('REV')),
219 219 ('', 'follow', None,
220 220 _('follow copies/renames and list the filename (DEPRECATED)')),
221 221 ('', 'no-follow', None, _("don't follow copies and renames")),
222 222 ('a', 'text', None, _('treat all files as text')),
223 223 ('u', 'user', None, _('list the author (long with -v)')),
224 224 ('f', 'file', None, _('list the filename')),
225 225 ('d', 'date', None, _('list the date (short with -q)')),
226 226 ('n', 'number', None, _('list the revision number (default)')),
227 227 ('c', 'changeset', None, _('list the changeset')),
228 228 ('l', 'line-number', None, _('show line number at the first appearance'))
229 229 ] + diffwsopts + walkopts,
230 230 _('[-r REV] [-f] [-a] [-u] [-d] [-n] [-c] [-l] FILE...'))
231 231 def annotate(ui, repo, *pats, **opts):
232 232 """show changeset information by line for each file
233 233
234 234 List changes in files, showing the revision id responsible for
235 235 each line
236 236
237 237 This command is useful for discovering when a change was made and
238 238 by whom.
239 239
240 240 Without the -a/--text option, annotate will avoid processing files
241 241 it detects as binary. With -a, annotate will annotate the file
242 242 anyway, although the results will probably be neither useful
243 243 nor desirable.
244 244
245 245 Returns 0 on success.
246 246 """
247 247 if opts.get('follow'):
248 248 # --follow is deprecated and now just an alias for -f/--file
249 249 # to mimic the behavior of Mercurial before version 1.5
250 250 opts['file'] = True
251 251
252 252 datefunc = ui.quiet and util.shortdate or util.datestr
253 253 getdate = util.cachefunc(lambda x: datefunc(x[0].date()))
254 254
255 255 if not pats:
256 256 raise util.Abort(_('at least one filename or pattern is required'))
257 257
258 258 hexfn = ui.debugflag and hex or short
259 259
260 260 opmap = [('user', ' ', lambda x: ui.shortuser(x[0].user())),
261 261 ('number', ' ', lambda x: str(x[0].rev())),
262 262 ('changeset', ' ', lambda x: hexfn(x[0].node())),
263 263 ('date', ' ', getdate),
264 264 ('file', ' ', lambda x: x[0].path()),
265 265 ('line_number', ':', lambda x: str(x[1])),
266 266 ]
267 267
268 268 if (not opts.get('user') and not opts.get('changeset')
269 269 and not opts.get('date') and not opts.get('file')):
270 270 opts['number'] = True
271 271
272 272 linenumber = opts.get('line_number') is not None
273 273 if linenumber and (not opts.get('changeset')) and (not opts.get('number')):
274 274 raise util.Abort(_('at least one of -n/-c is required for -l'))
275 275
276 276 funcmap = [(func, sep) for op, sep, func in opmap if opts.get(op)]
277 277 funcmap[0] = (funcmap[0][0], '') # no separator in front of first column
278 278
279 279 def bad(x, y):
280 280 raise util.Abort("%s: %s" % (x, y))
281 281
282 282 ctx = scmutil.revsingle(repo, opts.get('rev'))
283 283 m = scmutil.match(ctx, pats, opts)
284 284 m.bad = bad
285 285 follow = not opts.get('no_follow')
286 286 diffopts = patch.diffopts(ui, opts, section='annotate')
287 287 for abs in ctx.walk(m):
288 288 fctx = ctx[abs]
289 289 if not opts.get('text') and util.binary(fctx.data()):
290 290 ui.write(_("%s: binary file\n") % ((pats and m.rel(abs)) or abs))
291 291 continue
292 292
293 293 lines = fctx.annotate(follow=follow, linenumber=linenumber,
294 294 diffopts=diffopts)
295 295 pieces = []
296 296
297 297 for f, sep in funcmap:
298 298 l = [f(n) for n, dummy in lines]
299 299 if l:
300 300 sized = [(x, encoding.colwidth(x)) for x in l]
301 301 ml = max([w for x, w in sized])
302 302 pieces.append(["%s%s%s" % (sep, ' ' * (ml - w), x)
303 303 for x, w in sized])
304 304
305 305 if pieces:
306 306 for p, l in zip(zip(*pieces), lines):
307 307 ui.write("%s: %s" % ("".join(p), l[1]))
308 308
309 309 if lines and not lines[-1][1].endswith('\n'):
310 310 ui.write('\n')
311 311
312 312 @command('archive',
313 313 [('', 'no-decode', None, _('do not pass files through decoders')),
314 314 ('p', 'prefix', '', _('directory prefix for files in archive'),
315 315 _('PREFIX')),
316 316 ('r', 'rev', '', _('revision to distribute'), _('REV')),
317 317 ('t', 'type', '', _('type of distribution to create'), _('TYPE')),
318 318 ] + subrepoopts + walkopts,
319 319 _('[OPTION]... DEST'))
320 320 def archive(ui, repo, dest, **opts):
321 321 '''create an unversioned archive of a repository revision
322 322
323 323 By default, the revision used is the parent of the working
324 324 directory; use -r/--rev to specify a different revision.
325 325
326 326 The archive type is automatically detected based on file
327 327 extension (or override using -t/--type).
328 328
329 329 .. container:: verbose
330 330
331 331 Examples:
332 332
333 333 - create a zip file containing the 1.0 release::
334 334
335 335 hg archive -r 1.0 project-1.0.zip
336 336
337 337 - create a tarball excluding .hg files::
338 338
339 339 hg archive project.tar.gz -X ".hg*"
340 340
341 341 Valid types are:
342 342
343 343 :``files``: a directory full of files (default)
344 344 :``tar``: tar archive, uncompressed
345 345 :``tbz2``: tar archive, compressed using bzip2
346 346 :``tgz``: tar archive, compressed using gzip
347 347 :``uzip``: zip archive, uncompressed
348 348 :``zip``: zip archive, compressed using deflate
349 349
350 350 The exact name of the destination archive or directory is given
351 351 using a format string; see :hg:`help export` for details.
352 352
353 353 Each member added to an archive file has a directory prefix
354 354 prepended. Use -p/--prefix to specify a format string for the
355 355 prefix. The default is the basename of the archive, with suffixes
356 356 removed.
357 357
358 358 Returns 0 on success.
359 359 '''
360 360
361 361 ctx = scmutil.revsingle(repo, opts.get('rev'))
362 362 if not ctx:
363 363 raise util.Abort(_('no working directory: please specify a revision'))
364 364 node = ctx.node()
365 365 dest = cmdutil.makefilename(repo, dest, node)
366 366 if os.path.realpath(dest) == repo.root:
367 367 raise util.Abort(_('repository root cannot be destination'))
368 368
369 369 kind = opts.get('type') or archival.guesskind(dest) or 'files'
370 370 prefix = opts.get('prefix')
371 371
372 372 if dest == '-':
373 373 if kind == 'files':
374 374 raise util.Abort(_('cannot archive plain files to stdout'))
375 375 dest = cmdutil.makefileobj(repo, dest)
376 376 if not prefix:
377 377 prefix = os.path.basename(repo.root) + '-%h'
378 378
379 379 prefix = cmdutil.makefilename(repo, prefix, node)
380 380 matchfn = scmutil.match(ctx, [], opts)
381 381 archival.archive(repo, dest, node, kind, not opts.get('no_decode'),
382 382 matchfn, prefix, subrepos=opts.get('subrepos'))
383 383
384 384 @command('backout',
385 385 [('', 'merge', None, _('merge with old dirstate parent after backout')),
386 386 ('', 'parent', '',
387 387 _('parent to choose when backing out merge (DEPRECATED)'), _('REV')),
388 388 ('r', 'rev', '', _('revision to backout'), _('REV')),
389 389 ] + mergetoolopts + walkopts + commitopts + commitopts2,
390 390 _('[OPTION]... [-r] REV'))
391 391 def backout(ui, repo, node=None, rev=None, **opts):
392 392 '''reverse effect of earlier changeset
393 393
394 394 Prepare a new changeset with the effect of REV undone in the
395 395 current working directory.
396 396
397 397 If REV is the parent of the working directory, then this new changeset
398 398 is committed automatically. Otherwise, hg needs to merge the
399 399 changes and the merged result is left uncommitted.
400 400
401 401 .. note::
402 402
403 403 backout cannot be used to fix either an unwanted or
404 404 incorrect merge.
405 405
406 406 .. container:: verbose
407 407
408 408 By default, the pending changeset will have one parent,
409 409 maintaining a linear history. With --merge, the pending
410 410 changeset will instead have two parents: the old parent of the
411 411 working directory and a new child of REV that simply undoes REV.
412 412
413 413 Before version 1.7, the behavior without --merge was equivalent
414 414 to specifying --merge followed by :hg:`update --clean .` to
415 415 cancel the merge and leave the child of REV as a head to be
416 416 merged separately.
417 417
418 418 See :hg:`help dates` for a list of formats valid for -d/--date.
419 419
420 420 Returns 0 on success, 1 if nothing to backout or there are unresolved
421 421 files.
422 422 '''
423 423 if rev and node:
424 424 raise util.Abort(_("please specify just one revision"))
425 425
426 426 if not rev:
427 427 rev = node
428 428
429 429 if not rev:
430 430 raise util.Abort(_("please specify a revision to backout"))
431 431
432 432 date = opts.get('date')
433 433 if date:
434 434 opts['date'] = util.parsedate(date)
435 435
436 436 cmdutil.checkunfinished(repo)
437 437 cmdutil.bailifchanged(repo)
438 438 node = scmutil.revsingle(repo, rev).node()
439 439
440 440 op1, op2 = repo.dirstate.parents()
441 441 if node not in repo.changelog.commonancestorsheads(op1, node):
442 442 raise util.Abort(_('cannot backout change that is not an ancestor'))
443 443
444 444 p1, p2 = repo.changelog.parents(node)
445 445 if p1 == nullid:
446 446 raise util.Abort(_('cannot backout a change with no parents'))
447 447 if p2 != nullid:
448 448 if not opts.get('parent'):
449 449 raise util.Abort(_('cannot backout a merge changeset'))
450 450 p = repo.lookup(opts['parent'])
451 451 if p not in (p1, p2):
452 452 raise util.Abort(_('%s is not a parent of %s') %
453 453 (short(p), short(node)))
454 454 parent = p
455 455 else:
456 456 if opts.get('parent'):
457 457 raise util.Abort(_('cannot use --parent on non-merge changeset'))
458 458 parent = p1
459 459
460 460 # the backout should appear on the same branch
461 461 wlock = repo.wlock()
462 462 try:
463 463 branch = repo.dirstate.branch()
464 464 bheads = repo.branchheads(branch)
465 465 rctx = scmutil.revsingle(repo, hex(parent))
466 466 if not opts.get('merge') and op1 != node:
467 467 try:
468 468 ui.setconfig('ui', 'forcemerge', opts.get('tool', ''),
469 469 'backout')
470 470 stats = mergemod.update(repo, parent, True, True, False,
471 471 node, False)
472 472 repo.setparents(op1, op2)
473 473 hg._showstats(repo, stats)
474 474 if stats[3]:
475 475 repo.ui.status(_("use 'hg resolve' to retry unresolved "
476 476 "file merges\n"))
477 477 else:
478 478 msg = _("changeset %s backed out, "
479 479 "don't forget to commit.\n")
480 480 ui.status(msg % short(node))
481 481 return stats[3] > 0
482 482 finally:
483 483 ui.setconfig('ui', 'forcemerge', '', '')
484 484 else:
485 485 hg.clean(repo, node, show_stats=False)
486 486 repo.dirstate.setbranch(branch)
487 487 cmdutil.revert(ui, repo, rctx, repo.dirstate.parents())
488 488
489 489
490 490 e = cmdutil.commiteditor
491 491 if not opts['message'] and not opts['logfile']:
492 492 # we don't translate commit messages
493 493 opts['message'] = "Backed out changeset %s" % short(node)
494 494 e = cmdutil.commitforceeditor
495 495
496 496 def commitfunc(ui, repo, message, match, opts):
497 497 return repo.commit(message, opts.get('user'), opts.get('date'),
498 498 match, editor=e)
499 499 newnode = cmdutil.commit(ui, repo, commitfunc, [], opts)
500 500 if not newnode:
501 501 ui.status(_("nothing changed\n"))
502 502 return 1
503 503 cmdutil.commitstatus(repo, newnode, branch, bheads)
504 504
505 505 def nice(node):
506 506 return '%d:%s' % (repo.changelog.rev(node), short(node))
507 507 ui.status(_('changeset %s backs out changeset %s\n') %
508 508 (nice(repo.changelog.tip()), nice(node)))
509 509 if opts.get('merge') and op1 != node:
510 510 hg.clean(repo, op1, show_stats=False)
511 511 ui.status(_('merging with changeset %s\n')
512 512 % nice(repo.changelog.tip()))
513 513 try:
514 514 ui.setconfig('ui', 'forcemerge', opts.get('tool', ''),
515 515 'backout')
516 516 return hg.merge(repo, hex(repo.changelog.tip()))
517 517 finally:
518 518 ui.setconfig('ui', 'forcemerge', '', '')
519 519 finally:
520 520 wlock.release()
521 521 return 0
522 522
523 523 @command('bisect',
524 524 [('r', 'reset', False, _('reset bisect state')),
525 525 ('g', 'good', False, _('mark changeset good')),
526 526 ('b', 'bad', False, _('mark changeset bad')),
527 527 ('s', 'skip', False, _('skip testing changeset')),
528 528 ('e', 'extend', False, _('extend the bisect range')),
529 529 ('c', 'command', '', _('use command to check changeset state'), _('CMD')),
530 530 ('U', 'noupdate', False, _('do not update to target'))],
531 531 _("[-gbsr] [-U] [-c CMD] [REV]"))
532 532 def bisect(ui, repo, rev=None, extra=None, command=None,
533 533 reset=None, good=None, bad=None, skip=None, extend=None,
534 534 noupdate=None):
535 535 """subdivision search of changesets
536 536
537 537 This command helps to find changesets which introduce problems. To
538 538 use, mark the earliest changeset you know exhibits the problem as
539 539 bad, then mark the latest changeset which is free from the problem
540 540 as good. Bisect will update your working directory to a revision
541 541 for testing (unless the -U/--noupdate option is specified). Once
542 542 you have performed tests, mark the working directory as good or
543 543 bad, and bisect will either update to another candidate changeset
544 544 or announce that it has found the bad revision.
545 545
546 546 As a shortcut, you can also use the revision argument to mark a
547 547 revision as good or bad without checking it out first.
548 548
549 549 If you supply a command, it will be used for automatic bisection.
550 550 The environment variable HG_NODE will contain the ID of the
551 551 changeset being tested. The exit status of the command will be
552 552 used to mark revisions as good or bad: status 0 means good, 125
553 553 means to skip the revision, 127 (command not found) will abort the
554 554 bisection, and any other non-zero exit status means the revision
555 555 is bad.
556 556
557 557 .. container:: verbose
558 558
559 559 Some examples:
560 560
561 561 - start a bisection with known bad revision 34, and good revision 12::
562 562
563 563 hg bisect --bad 34
564 564 hg bisect --good 12
565 565
566 566 - advance the current bisection by marking current revision as good or
567 567 bad::
568 568
569 569 hg bisect --good
570 570 hg bisect --bad
571 571
572 572 - mark the current revision, or a known revision, to be skipped (e.g. if
573 573 that revision is not usable because of another issue)::
574 574
575 575 hg bisect --skip
576 576 hg bisect --skip 23
577 577
578 578 - skip all revisions that do not touch directories ``foo`` or ``bar``::
579 579
580 580 hg bisect --skip "!( file('path:foo') & file('path:bar') )"
581 581
582 582 - forget the current bisection::
583 583
584 584 hg bisect --reset
585 585
586 586 - use 'make && make tests' to automatically find the first broken
587 587 revision::
588 588
589 589 hg bisect --reset
590 590 hg bisect --bad 34
591 591 hg bisect --good 12
592 592 hg bisect --command "make && make tests"
593 593
594 594 - see all changesets whose states are already known in the current
595 595 bisection::
596 596
597 597 hg log -r "bisect(pruned)"
598 598
599 599 - see the changeset currently being bisected (especially useful
600 600 if running with -U/--noupdate)::
601 601
602 602 hg log -r "bisect(current)"
603 603
604 604 - see all changesets that took part in the current bisection::
605 605
606 606 hg log -r "bisect(range)"
607 607
608 608 - you can even get a nice graph::
609 609
610 610 hg log --graph -r "bisect(range)"
611 611
612 612 See :hg:`help revsets` for more about the `bisect()` keyword.
613 613
614 614 Returns 0 on success.
615 615 """
616 616 def extendbisectrange(nodes, good):
617 617 # bisect is incomplete when it ends on a merge node and
618 618 # one of the parent was not checked.
619 619 parents = repo[nodes[0]].parents()
620 620 if len(parents) > 1:
621 621 side = good and state['bad'] or state['good']
622 622 num = len(set(i.node() for i in parents) & set(side))
623 623 if num == 1:
624 624 return parents[0].ancestor(parents[1])
625 625 return None
626 626
627 627 def print_result(nodes, good):
628 628 displayer = cmdutil.show_changeset(ui, repo, {})
629 629 if len(nodes) == 1:
630 630 # narrowed it down to a single revision
631 631 if good:
632 632 ui.write(_("The first good revision is:\n"))
633 633 else:
634 634 ui.write(_("The first bad revision is:\n"))
635 635 displayer.show(repo[nodes[0]])
636 636 extendnode = extendbisectrange(nodes, good)
637 637 if extendnode is not None:
638 638 ui.write(_('Not all ancestors of this changeset have been'
639 639 ' checked.\nUse bisect --extend to continue the '
640 640 'bisection from\nthe common ancestor, %s.\n')
641 641 % extendnode)
642 642 else:
643 643 # multiple possible revisions
644 644 if good:
645 645 ui.write(_("Due to skipped revisions, the first "
646 646 "good revision could be any of:\n"))
647 647 else:
648 648 ui.write(_("Due to skipped revisions, the first "
649 649 "bad revision could be any of:\n"))
650 650 for n in nodes:
651 651 displayer.show(repo[n])
652 652 displayer.close()
653 653
654 654 def check_state(state, interactive=True):
655 655 if not state['good'] or not state['bad']:
656 656 if (good or bad or skip or reset) and interactive:
657 657 return
658 658 if not state['good']:
659 659 raise util.Abort(_('cannot bisect (no known good revisions)'))
660 660 else:
661 661 raise util.Abort(_('cannot bisect (no known bad revisions)'))
662 662 return True
663 663
664 664 # backward compatibility
665 665 if rev in "good bad reset init".split():
666 666 ui.warn(_("(use of 'hg bisect <cmd>' is deprecated)\n"))
667 667 cmd, rev, extra = rev, extra, None
668 668 if cmd == "good":
669 669 good = True
670 670 elif cmd == "bad":
671 671 bad = True
672 672 else:
673 673 reset = True
674 674 elif extra or good + bad + skip + reset + extend + bool(command) > 1:
675 675 raise util.Abort(_('incompatible arguments'))
676 676
677 677 cmdutil.checkunfinished(repo)
678 678
679 679 if reset:
680 680 p = repo.join("bisect.state")
681 681 if os.path.exists(p):
682 682 os.unlink(p)
683 683 return
684 684
685 685 state = hbisect.load_state(repo)
686 686
687 687 if command:
688 688 changesets = 1
689 689 if noupdate:
690 690 try:
691 691 node = state['current'][0]
692 692 except LookupError:
693 693 raise util.Abort(_('current bisect revision is unknown - '
694 694 'start a new bisect to fix'))
695 695 else:
696 696 node, p2 = repo.dirstate.parents()
697 697 if p2 != nullid:
698 698 raise util.Abort(_('current bisect revision is a merge'))
699 699 try:
700 700 while changesets:
701 701 # update state
702 702 state['current'] = [node]
703 703 hbisect.save_state(repo, state)
704 704 status = util.system(command,
705 705 environ={'HG_NODE': hex(node)},
706 706 out=ui.fout)
707 707 if status == 125:
708 708 transition = "skip"
709 709 elif status == 0:
710 710 transition = "good"
711 711 # status < 0 means process was killed
712 712 elif status == 127:
713 713 raise util.Abort(_("failed to execute %s") % command)
714 714 elif status < 0:
715 715 raise util.Abort(_("%s killed") % command)
716 716 else:
717 717 transition = "bad"
718 718 ctx = scmutil.revsingle(repo, rev, node)
719 719 rev = None # clear for future iterations
720 720 state[transition].append(ctx.node())
721 721 ui.status(_('changeset %d:%s: %s\n') % (ctx, ctx, transition))
722 722 check_state(state, interactive=False)
723 723 # bisect
724 724 nodes, changesets, bgood = hbisect.bisect(repo.changelog, state)
725 725 # update to next check
726 726 node = nodes[0]
727 727 if not noupdate:
728 728 cmdutil.bailifchanged(repo)
729 729 hg.clean(repo, node, show_stats=False)
730 730 finally:
731 731 state['current'] = [node]
732 732 hbisect.save_state(repo, state)
733 733 print_result(nodes, bgood)
734 734 return
735 735
736 736 # update state
737 737
738 738 if rev:
739 739 nodes = [repo.lookup(i) for i in scmutil.revrange(repo, [rev])]
740 740 else:
741 741 nodes = [repo.lookup('.')]
742 742
743 743 if good or bad or skip:
744 744 if good:
745 745 state['good'] += nodes
746 746 elif bad:
747 747 state['bad'] += nodes
748 748 elif skip:
749 749 state['skip'] += nodes
750 750 hbisect.save_state(repo, state)
751 751
752 752 if not check_state(state):
753 753 return
754 754
755 755 # actually bisect
756 756 nodes, changesets, good = hbisect.bisect(repo.changelog, state)
757 757 if extend:
758 758 if not changesets:
759 759 extendnode = extendbisectrange(nodes, good)
760 760 if extendnode is not None:
761 761 ui.write(_("Extending search to changeset %d:%s\n")
762 762 % (extendnode.rev(), extendnode))
763 763 state['current'] = [extendnode.node()]
764 764 hbisect.save_state(repo, state)
765 765 if noupdate:
766 766 return
767 767 cmdutil.bailifchanged(repo)
768 768 return hg.clean(repo, extendnode.node())
769 769 raise util.Abort(_("nothing to extend"))
770 770
771 771 if changesets == 0:
772 772 print_result(nodes, good)
773 773 else:
774 774 assert len(nodes) == 1 # only a single node can be tested next
775 775 node = nodes[0]
776 776 # compute the approximate number of remaining tests
777 777 tests, size = 0, 2
778 778 while size <= changesets:
779 779 tests, size = tests + 1, size * 2
780 780 rev = repo.changelog.rev(node)
781 781 ui.write(_("Testing changeset %d:%s "
782 782 "(%d changesets remaining, ~%d tests)\n")
783 783 % (rev, short(node), changesets, tests))
784 784 state['current'] = [node]
785 785 hbisect.save_state(repo, state)
786 786 if not noupdate:
787 787 cmdutil.bailifchanged(repo)
788 788 return hg.clean(repo, node)
789 789
790 790 @command('bookmarks|bookmark',
791 791 [('f', 'force', False, _('force')),
792 792 ('r', 'rev', '', _('revision'), _('REV')),
793 793 ('d', 'delete', False, _('delete a given bookmark')),
794 794 ('m', 'rename', '', _('rename a given bookmark'), _('NAME')),
795 795 ('i', 'inactive', False, _('mark a bookmark inactive'))],
796 796 _('hg bookmarks [OPTIONS]... [NAME]...'))
797 797 def bookmark(ui, repo, *names, **opts):
798 798 '''track a line of development with movable markers
799 799
800 800 Bookmarks are pointers to certain commits that move when committing.
801 801 Bookmarks are local. They can be renamed, copied and deleted. It is
802 802 possible to use :hg:`merge NAME` to merge from a given bookmark, and
803 803 :hg:`update NAME` to update to a given bookmark.
804 804
805 805 You can use :hg:`bookmark NAME` to set a bookmark on the working
806 806 directory's parent revision with the given name. If you specify
807 807 a revision using -r REV (where REV may be an existing bookmark),
808 808 the bookmark is assigned to that revision.
809 809
810 810 Bookmarks can be pushed and pulled between repositories (see :hg:`help
811 811 push` and :hg:`help pull`). This requires both the local and remote
812 812 repositories to support bookmarks. For versions prior to 1.8, this means
813 813 the bookmarks extension must be enabled.
814 814
815 815 If you set a bookmark called '@', new clones of the repository will
816 816 have that revision checked out (and the bookmark made active) by
817 817 default.
818 818
819 819 With -i/--inactive, the new bookmark will not be made the active
820 820 bookmark. If -r/--rev is given, the new bookmark will not be made
821 821 active even if -i/--inactive is not given. If no NAME is given, the
822 822 current active bookmark will be marked inactive.
823 823 '''
824 824 force = opts.get('force')
825 825 rev = opts.get('rev')
826 826 delete = opts.get('delete')
827 827 rename = opts.get('rename')
828 828 inactive = opts.get('inactive')
829 829
830 830 def checkformat(mark):
831 831 mark = mark.strip()
832 832 if not mark:
833 833 raise util.Abort(_("bookmark names cannot consist entirely of "
834 834 "whitespace"))
835 835 scmutil.checknewlabel(repo, mark, 'bookmark')
836 836 return mark
837 837
838 838 def checkconflict(repo, mark, cur, force=False, target=None):
839 839 if mark in marks and not force:
840 840 if target:
841 841 if marks[mark] == target and target == cur:
842 842 # re-activating a bookmark
843 843 return
844 844 anc = repo.changelog.ancestors([repo[target].rev()])
845 845 bmctx = repo[marks[mark]]
846 846 divs = [repo[b].node() for b in marks
847 847 if b.split('@', 1)[0] == mark.split('@', 1)[0]]
848 848
849 849 # allow resolving a single divergent bookmark even if moving
850 850 # the bookmark across branches when a revision is specified
851 851 # that contains a divergent bookmark
852 852 if bmctx.rev() not in anc and target in divs:
853 853 bookmarks.deletedivergent(repo, [target], mark)
854 854 return
855 855
856 856 deletefrom = [b for b in divs
857 857 if repo[b].rev() in anc or b == target]
858 858 bookmarks.deletedivergent(repo, deletefrom, mark)
859 859 if bookmarks.validdest(repo, bmctx, repo[target]):
860 860 ui.status(_("moving bookmark '%s' forward from %s\n") %
861 861 (mark, short(bmctx.node())))
862 862 return
863 863 raise util.Abort(_("bookmark '%s' already exists "
864 864 "(use -f to force)") % mark)
865 865 if ((mark in repo.branchmap() or mark == repo.dirstate.branch())
866 866 and not force):
867 867 raise util.Abort(
868 868 _("a bookmark cannot have the name of an existing branch"))
869 869
870 870 if delete and rename:
871 871 raise util.Abort(_("--delete and --rename are incompatible"))
872 872 if delete and rev:
873 873 raise util.Abort(_("--rev is incompatible with --delete"))
874 874 if rename and rev:
875 875 raise util.Abort(_("--rev is incompatible with --rename"))
876 876 if not names and (delete or rev):
877 877 raise util.Abort(_("bookmark name required"))
878 878
879 879 if delete or rename or names or inactive:
880 880 wlock = repo.wlock()
881 881 try:
882 882 cur = repo.changectx('.').node()
883 883 marks = repo._bookmarks
884 884 if delete:
885 885 for mark in names:
886 886 if mark not in marks:
887 887 raise util.Abort(_("bookmark '%s' does not exist") %
888 888 mark)
889 889 if mark == repo._bookmarkcurrent:
890 890 bookmarks.unsetcurrent(repo)
891 891 del marks[mark]
892 892 marks.write()
893 893
894 894 elif rename:
895 895 if not names:
896 896 raise util.Abort(_("new bookmark name required"))
897 897 elif len(names) > 1:
898 898 raise util.Abort(_("only one new bookmark name allowed"))
899 899 mark = checkformat(names[0])
900 900 if rename not in marks:
901 901 raise util.Abort(_("bookmark '%s' does not exist") % rename)
902 902 checkconflict(repo, mark, cur, force)
903 903 marks[mark] = marks[rename]
904 904 if repo._bookmarkcurrent == rename and not inactive:
905 905 bookmarks.setcurrent(repo, mark)
906 906 del marks[rename]
907 907 marks.write()
908 908
909 909 elif names:
910 910 newact = None
911 911 for mark in names:
912 912 mark = checkformat(mark)
913 913 if newact is None:
914 914 newact = mark
915 915 if inactive and mark == repo._bookmarkcurrent:
916 916 bookmarks.unsetcurrent(repo)
917 917 return
918 918 tgt = cur
919 919 if rev:
920 920 tgt = scmutil.revsingle(repo, rev).node()
921 921 checkconflict(repo, mark, cur, force, tgt)
922 922 marks[mark] = tgt
923 923 if not inactive and cur == marks[newact] and not rev:
924 924 bookmarks.setcurrent(repo, newact)
925 925 elif cur != tgt and newact == repo._bookmarkcurrent:
926 926 bookmarks.unsetcurrent(repo)
927 927 marks.write()
928 928
929 929 elif inactive:
930 930 if len(marks) == 0:
931 931 ui.status(_("no bookmarks set\n"))
932 932 elif not repo._bookmarkcurrent:
933 933 ui.status(_("no active bookmark\n"))
934 934 else:
935 935 bookmarks.unsetcurrent(repo)
936 936 finally:
937 937 wlock.release()
938 938 else: # show bookmarks
939 939 hexfn = ui.debugflag and hex or short
940 940 marks = repo._bookmarks
941 941 if len(marks) == 0:
942 942 ui.status(_("no bookmarks set\n"))
943 943 else:
944 944 for bmark, n in sorted(marks.iteritems()):
945 945 current = repo._bookmarkcurrent
946 946 if bmark == current:
947 947 prefix, label = '*', 'bookmarks.current'
948 948 else:
949 949 prefix, label = ' ', ''
950 950
951 951 if ui.quiet:
952 952 ui.write("%s\n" % bmark, label=label)
953 953 else:
954 954 ui.write(" %s %-25s %d:%s\n" % (
955 955 prefix, bmark, repo.changelog.rev(n), hexfn(n)),
956 956 label=label)
957 957
958 958 @command('branch',
959 959 [('f', 'force', None,
960 960 _('set branch name even if it shadows an existing branch')),
961 961 ('C', 'clean', None, _('reset branch name to parent branch name'))],
962 962 _('[-fC] [NAME]'))
963 963 def branch(ui, repo, label=None, **opts):
964 964 """set or show the current branch name
965 965
966 966 .. note::
967 967
968 968 Branch names are permanent and global. Use :hg:`bookmark` to create a
969 969 light-weight bookmark instead. See :hg:`help glossary` for more
970 970 information about named branches and bookmarks.
971 971
972 972 With no argument, show the current branch name. With one argument,
973 973 set the working directory branch name (the branch will not exist
974 974 in the repository until the next commit). Standard practice
975 975 recommends that primary development take place on the 'default'
976 976 branch.
977 977
978 978 Unless -f/--force is specified, branch will not let you set a
979 979 branch name that already exists, even if it's inactive.
980 980
981 981 Use -C/--clean to reset the working directory branch to that of
982 982 the parent of the working directory, negating a previous branch
983 983 change.
984 984
985 985 Use the command :hg:`update` to switch to an existing branch. Use
986 986 :hg:`commit --close-branch` to mark this branch as closed.
987 987
988 988 Returns 0 on success.
989 989 """
990 990 if label:
991 991 label = label.strip()
992 992
993 993 if not opts.get('clean') and not label:
994 994 ui.write("%s\n" % repo.dirstate.branch())
995 995 return
996 996
997 997 wlock = repo.wlock()
998 998 try:
999 999 if opts.get('clean'):
1000 1000 label = repo[None].p1().branch()
1001 1001 repo.dirstate.setbranch(label)
1002 1002 ui.status(_('reset working directory to branch %s\n') % label)
1003 1003 elif label:
1004 1004 if not opts.get('force') and label in repo.branchmap():
1005 1005 if label not in [p.branch() for p in repo.parents()]:
1006 1006 raise util.Abort(_('a branch of the same name already'
1007 1007 ' exists'),
1008 1008 # i18n: "it" refers to an existing branch
1009 1009 hint=_("use 'hg update' to switch to it"))
1010 1010 scmutil.checknewlabel(repo, label, 'branch')
1011 1011 repo.dirstate.setbranch(label)
1012 1012 ui.status(_('marked working directory as branch %s\n') % label)
1013 1013 ui.status(_('(branches are permanent and global, '
1014 1014 'did you want a bookmark?)\n'))
1015 1015 finally:
1016 1016 wlock.release()
1017 1017
1018 1018 @command('branches',
1019 1019 [('a', 'active', False, _('show only branches that have unmerged heads')),
1020 1020 ('c', 'closed', False, _('show normal and closed branches'))],
1021 1021 _('[-ac]'))
1022 1022 def branches(ui, repo, active=False, closed=False):
1023 1023 """list repository named branches
1024 1024
1025 1025 List the repository's named branches, indicating which ones are
1026 1026 inactive. If -c/--closed is specified, also list branches which have
1027 1027 been marked closed (see :hg:`commit --close-branch`).
1028 1028
1029 1029 If -a/--active is specified, only show active branches. A branch
1030 1030 is considered active if it contains repository heads.
1031 1031
1032 1032 Use the command :hg:`update` to switch to an existing branch.
1033 1033
1034 1034 Returns 0.
1035 1035 """
1036 1036
1037 1037 hexfunc = ui.debugflag and hex or short
1038 1038
1039 1039 allheads = set(repo.heads())
1040 1040 branches = []
1041 1041 for tag, heads, tip, isclosed in repo.branchmap().iterbranches():
1042 1042 isactive = not isclosed and bool(set(heads) & allheads)
1043 1043 branches.append((tag, repo[tip], isactive, not isclosed))
1044 1044 branches.sort(key=lambda i: (i[2], i[1].rev(), i[0], i[3]),
1045 1045 reverse=True)
1046 1046
1047 1047 for tag, ctx, isactive, isopen in branches:
1048 1048 if (not active) or isactive:
1049 1049 if isactive:
1050 1050 label = 'branches.active'
1051 1051 notice = ''
1052 1052 elif not isopen:
1053 1053 if not closed:
1054 1054 continue
1055 1055 label = 'branches.closed'
1056 1056 notice = _(' (closed)')
1057 1057 else:
1058 1058 label = 'branches.inactive'
1059 1059 notice = _(' (inactive)')
1060 1060 if tag == repo.dirstate.branch():
1061 1061 label = 'branches.current'
1062 1062 rev = str(ctx.rev()).rjust(31 - encoding.colwidth(tag))
1063 1063 rev = ui.label('%s:%s' % (rev, hexfunc(ctx.node())),
1064 1064 'log.changeset changeset.%s' % ctx.phasestr())
1065 1065 labeledtag = ui.label(tag, label)
1066 1066 if ui.quiet:
1067 1067 ui.write("%s\n" % labeledtag)
1068 1068 else:
1069 1069 ui.write("%s %s%s\n" % (labeledtag, rev, notice))
1070 1070
1071 1071 @command('bundle',
1072 1072 [('f', 'force', None, _('run even when the destination is unrelated')),
1073 1073 ('r', 'rev', [], _('a changeset intended to be added to the destination'),
1074 1074 _('REV')),
1075 1075 ('b', 'branch', [], _('a specific branch you would like to bundle'),
1076 1076 _('BRANCH')),
1077 1077 ('', 'base', [],
1078 1078 _('a base changeset assumed to be available at the destination'),
1079 1079 _('REV')),
1080 1080 ('a', 'all', None, _('bundle all changesets in the repository')),
1081 1081 ('t', 'type', 'bzip2', _('bundle compression type to use'), _('TYPE')),
1082 1082 ] + remoteopts,
1083 1083 _('[-f] [-t TYPE] [-a] [-r REV]... [--base REV]... FILE [DEST]'))
1084 1084 def bundle(ui, repo, fname, dest=None, **opts):
1085 1085 """create a changegroup file
1086 1086
1087 1087 Generate a compressed changegroup file collecting changesets not
1088 1088 known to be in another repository.
1089 1089
1090 1090 If you omit the destination repository, then hg assumes the
1091 1091 destination will have all the nodes you specify with --base
1092 1092 parameters. To create a bundle containing all changesets, use
1093 1093 -a/--all (or --base null).
1094 1094
1095 1095 You can change compression method with the -t/--type option.
1096 1096 The available compression methods are: none, bzip2, and
1097 1097 gzip (by default, bundles are compressed using bzip2).
1098 1098
1099 1099 The bundle file can then be transferred using conventional means
1100 1100 and applied to another repository with the unbundle or pull
1101 1101 command. This is useful when direct push and pull are not
1102 1102 available or when exporting an entire repository is undesirable.
1103 1103
1104 1104 Applying bundles preserves all changeset contents including
1105 1105 permissions, copy/rename information, and revision history.
1106 1106
1107 1107 Returns 0 on success, 1 if no changes found.
1108 1108 """
1109 1109 revs = None
1110 1110 if 'rev' in opts:
1111 1111 revs = scmutil.revrange(repo, opts['rev'])
1112 1112
1113 1113 bundletype = opts.get('type', 'bzip2').lower()
1114 1114 btypes = {'none': 'HG10UN', 'bzip2': 'HG10BZ', 'gzip': 'HG10GZ'}
1115 1115 bundletype = btypes.get(bundletype)
1116 1116 if bundletype not in changegroup.bundletypes:
1117 1117 raise util.Abort(_('unknown bundle type specified with --type'))
1118 1118
1119 1119 if opts.get('all'):
1120 1120 base = ['null']
1121 1121 else:
1122 1122 base = scmutil.revrange(repo, opts.get('base'))
1123 1123 # TODO: get desired bundlecaps from command line.
1124 1124 bundlecaps = None
1125 1125 if base:
1126 1126 if dest:
1127 1127 raise util.Abort(_("--base is incompatible with specifying "
1128 1128 "a destination"))
1129 1129 common = [repo.lookup(rev) for rev in base]
1130 1130 heads = revs and map(repo.lookup, revs) or revs
1131 1131 cg = changegroup.getbundle(repo, 'bundle', heads=heads, common=common,
1132 1132 bundlecaps=bundlecaps)
1133 1133 outgoing = None
1134 1134 else:
1135 1135 dest = ui.expandpath(dest or 'default-push', dest or 'default')
1136 1136 dest, branches = hg.parseurl(dest, opts.get('branch'))
1137 1137 other = hg.peer(repo, opts, dest)
1138 1138 revs, checkout = hg.addbranchrevs(repo, repo, branches, revs)
1139 1139 heads = revs and map(repo.lookup, revs) or revs
1140 1140 outgoing = discovery.findcommonoutgoing(repo, other,
1141 1141 onlyheads=heads,
1142 1142 force=opts.get('force'),
1143 1143 portable=True)
1144 1144 cg = changegroup.getlocalbundle(repo, 'bundle', outgoing, bundlecaps)
1145 1145 if not cg:
1146 1146 scmutil.nochangesfound(ui, repo, outgoing and outgoing.excluded)
1147 1147 return 1
1148 1148
1149 1149 changegroup.writebundle(cg, fname, bundletype)
1150 1150
1151 1151 @command('cat',
1152 1152 [('o', 'output', '',
1153 1153 _('print output to file with formatted name'), _('FORMAT')),
1154 1154 ('r', 'rev', '', _('print the given revision'), _('REV')),
1155 1155 ('', 'decode', None, _('apply any matching decode filter')),
1156 1156 ] + walkopts,
1157 1157 _('[OPTION]... FILE...'))
1158 1158 def cat(ui, repo, file1, *pats, **opts):
1159 1159 """output the current or given revision of files
1160 1160
1161 1161 Print the specified files as they were at the given revision. If
1162 1162 no revision is given, the parent of the working directory is used.
1163 1163
1164 1164 Output may be to a file, in which case the name of the file is
1165 1165 given using a format string. The formatting rules as follows:
1166 1166
1167 1167 :``%%``: literal "%" character
1168 1168 :``%s``: basename of file being printed
1169 1169 :``%d``: dirname of file being printed, or '.' if in repository root
1170 1170 :``%p``: root-relative path name of file being printed
1171 1171 :``%H``: changeset hash (40 hexadecimal digits)
1172 1172 :``%R``: changeset revision number
1173 1173 :``%h``: short-form changeset hash (12 hexadecimal digits)
1174 1174 :``%r``: zero-padded changeset revision number
1175 1175 :``%b``: basename of the exporting repository
1176 1176
1177 1177 Returns 0 on success.
1178 1178 """
1179 1179 ctx = scmutil.revsingle(repo, opts.get('rev'))
1180 1180 m = scmutil.match(ctx, (file1,) + pats, opts)
1181 1181
1182 1182 return cmdutil.cat(ui, repo, ctx, m, '', **opts)
1183 1183
1184 1184 @command('^clone',
1185 1185 [('U', 'noupdate', None,
1186 1186 _('the clone will include an empty working copy (only a repository)')),
1187 1187 ('u', 'updaterev', '', _('revision, tag or branch to check out'), _('REV')),
1188 1188 ('r', 'rev', [], _('include the specified changeset'), _('REV')),
1189 1189 ('b', 'branch', [], _('clone only the specified branch'), _('BRANCH')),
1190 1190 ('', 'pull', None, _('use pull protocol to copy metadata')),
1191 1191 ('', 'uncompressed', None, _('use uncompressed transfer (fast over LAN)')),
1192 1192 ] + remoteopts,
1193 1193 _('[OPTION]... SOURCE [DEST]'))
1194 1194 def clone(ui, source, dest=None, **opts):
1195 1195 """make a copy of an existing repository
1196 1196
1197 1197 Create a copy of an existing repository in a new directory.
1198 1198
1199 1199 If no destination directory name is specified, it defaults to the
1200 1200 basename of the source.
1201 1201
1202 1202 The location of the source is added to the new repository's
1203 1203 ``.hg/hgrc`` file, as the default to be used for future pulls.
1204 1204
1205 1205 Only local paths and ``ssh://`` URLs are supported as
1206 1206 destinations. For ``ssh://`` destinations, no working directory or
1207 1207 ``.hg/hgrc`` will be created on the remote side.
1208 1208
1209 1209 To pull only a subset of changesets, specify one or more revisions
1210 1210 identifiers with -r/--rev or branches with -b/--branch. The
1211 1211 resulting clone will contain only the specified changesets and
1212 1212 their ancestors. These options (or 'clone src#rev dest') imply
1213 1213 --pull, even for local source repositories. Note that specifying a
1214 1214 tag will include the tagged changeset but not the changeset
1215 1215 containing the tag.
1216 1216
1217 1217 If the source repository has a bookmark called '@' set, that
1218 1218 revision will be checked out in the new repository by default.
1219 1219
1220 1220 To check out a particular version, use -u/--update, or
1221 1221 -U/--noupdate to create a clone with no working directory.
1222 1222
1223 1223 .. container:: verbose
1224 1224
1225 1225 For efficiency, hardlinks are used for cloning whenever the
1226 1226 source and destination are on the same filesystem (note this
1227 1227 applies only to the repository data, not to the working
1228 1228 directory). Some filesystems, such as AFS, implement hardlinking
1229 1229 incorrectly, but do not report errors. In these cases, use the
1230 1230 --pull option to avoid hardlinking.
1231 1231
1232 1232 In some cases, you can clone repositories and the working
1233 1233 directory using full hardlinks with ::
1234 1234
1235 1235 $ cp -al REPO REPOCLONE
1236 1236
1237 1237 This is the fastest way to clone, but it is not always safe. The
1238 1238 operation is not atomic (making sure REPO is not modified during
1239 1239 the operation is up to you) and you have to make sure your
1240 1240 editor breaks hardlinks (Emacs and most Linux Kernel tools do
1241 1241 so). Also, this is not compatible with certain extensions that
1242 1242 place their metadata under the .hg directory, such as mq.
1243 1243
1244 1244 Mercurial will update the working directory to the first applicable
1245 1245 revision from this list:
1246 1246
1247 1247 a) null if -U or the source repository has no changesets
1248 1248 b) if -u . and the source repository is local, the first parent of
1249 1249 the source repository's working directory
1250 1250 c) the changeset specified with -u (if a branch name, this means the
1251 1251 latest head of that branch)
1252 1252 d) the changeset specified with -r
1253 1253 e) the tipmost head specified with -b
1254 1254 f) the tipmost head specified with the url#branch source syntax
1255 1255 g) the revision marked with the '@' bookmark, if present
1256 1256 h) the tipmost head of the default branch
1257 1257 i) tip
1258 1258
1259 1259 Examples:
1260 1260
1261 1261 - clone a remote repository to a new directory named hg/::
1262 1262
1263 1263 hg clone http://selenic.com/hg
1264 1264
1265 1265 - create a lightweight local clone::
1266 1266
1267 1267 hg clone project/ project-feature/
1268 1268
1269 1269 - clone from an absolute path on an ssh server (note double-slash)::
1270 1270
1271 1271 hg clone ssh://user@server//home/projects/alpha/
1272 1272
1273 1273 - do a high-speed clone over a LAN while checking out a
1274 1274 specified version::
1275 1275
1276 1276 hg clone --uncompressed http://server/repo -u 1.5
1277 1277
1278 1278 - create a repository without changesets after a particular revision::
1279 1279
1280 1280 hg clone -r 04e544 experimental/ good/
1281 1281
1282 1282 - clone (and track) a particular named branch::
1283 1283
1284 1284 hg clone http://selenic.com/hg#stable
1285 1285
1286 1286 See :hg:`help urls` for details on specifying URLs.
1287 1287
1288 1288 Returns 0 on success.
1289 1289 """
1290 1290 if opts.get('noupdate') and opts.get('updaterev'):
1291 1291 raise util.Abort(_("cannot specify both --noupdate and --updaterev"))
1292 1292
1293 1293 r = hg.clone(ui, opts, source, dest,
1294 1294 pull=opts.get('pull'),
1295 1295 stream=opts.get('uncompressed'),
1296 1296 rev=opts.get('rev'),
1297 1297 update=opts.get('updaterev') or not opts.get('noupdate'),
1298 1298 branch=opts.get('branch'))
1299 1299
1300 1300 return r is None
1301 1301
1302 1302 @command('^commit|ci',
1303 1303 [('A', 'addremove', None,
1304 1304 _('mark new/missing files as added/removed before committing')),
1305 1305 ('', 'close-branch', None,
1306 1306 _('mark a branch as closed, hiding it from the branch list')),
1307 1307 ('', 'amend', None, _('amend the parent of the working dir')),
1308 1308 ('s', 'secret', None, _('use the secret phase for committing')),
1309 1309 ('e', 'edit', None,
1310 1310 _('further edit commit message already specified')),
1311 1311 ] + walkopts + commitopts + commitopts2 + subrepoopts,
1312 1312 _('[OPTION]... [FILE]...'))
1313 1313 def commit(ui, repo, *pats, **opts):
1314 1314 """commit the specified files or all outstanding changes
1315 1315
1316 1316 Commit changes to the given files into the repository. Unlike a
1317 1317 centralized SCM, this operation is a local operation. See
1318 1318 :hg:`push` for a way to actively distribute your changes.
1319 1319
1320 1320 If a list of files is omitted, all changes reported by :hg:`status`
1321 1321 will be committed.
1322 1322
1323 1323 If you are committing the result of a merge, do not provide any
1324 1324 filenames or -I/-X filters.
1325 1325
1326 1326 If no commit message is specified, Mercurial starts your
1327 1327 configured editor where you can enter a message. In case your
1328 1328 commit fails, you will find a backup of your message in
1329 1329 ``.hg/last-message.txt``.
1330 1330
1331 1331 The --amend flag can be used to amend the parent of the
1332 1332 working directory with a new commit that contains the changes
1333 1333 in the parent in addition to those currently reported by :hg:`status`,
1334 1334 if there are any. The old commit is stored in a backup bundle in
1335 1335 ``.hg/strip-backup`` (see :hg:`help bundle` and :hg:`help unbundle`
1336 1336 on how to restore it).
1337 1337
1338 1338 Message, user and date are taken from the amended commit unless
1339 1339 specified. When a message isn't specified on the command line,
1340 1340 the editor will open with the message of the amended commit.
1341 1341
1342 1342 It is not possible to amend public changesets (see :hg:`help phases`)
1343 1343 or changesets that have children.
1344 1344
1345 1345 See :hg:`help dates` for a list of formats valid for -d/--date.
1346 1346
1347 1347 Returns 0 on success, 1 if nothing changed.
1348 1348 """
1349 1349 forceeditor = opts.get('edit')
1350 1350
1351 1351 if opts.get('subrepos'):
1352 1352 if opts.get('amend'):
1353 1353 raise util.Abort(_('cannot amend with --subrepos'))
1354 1354 # Let --subrepos on the command line override config setting.
1355 1355 ui.setconfig('ui', 'commitsubrepos', True, 'commit')
1356 1356
1357 1357 # Save this for restoring it later
1358 1358 oldcommitphase = ui.config('phases', 'new-commit')
1359 1359
1360 1360 cmdutil.checkunfinished(repo, commit=True)
1361 1361
1362 1362 branch = repo[None].branch()
1363 1363 bheads = repo.branchheads(branch)
1364 1364
1365 1365 extra = {}
1366 1366 if opts.get('close_branch'):
1367 1367 extra['close'] = 1
1368 1368
1369 1369 if not bheads:
1370 1370 raise util.Abort(_('can only close branch heads'))
1371 1371 elif opts.get('amend'):
1372 1372 if repo.parents()[0].p1().branch() != branch and \
1373 1373 repo.parents()[0].p2().branch() != branch:
1374 1374 raise util.Abort(_('can only close branch heads'))
1375 1375
1376 1376 if opts.get('amend'):
1377 1377 if ui.configbool('ui', 'commitsubrepos'):
1378 1378 raise util.Abort(_('cannot amend with ui.commitsubrepos enabled'))
1379 1379
1380 1380 old = repo['.']
1381 1381 if old.phase() == phases.public:
1382 1382 raise util.Abort(_('cannot amend public changesets'))
1383 1383 if len(repo[None].parents()) > 1:
1384 1384 raise util.Abort(_('cannot amend while merging'))
1385 1385 if (not obsolete._enabled) and old.children():
1386 1386 raise util.Abort(_('cannot amend changeset with children'))
1387 1387
1388 1388 # commitfunc is used only for temporary amend commit by cmdutil.amend
1389 1389 def commitfunc(ui, repo, message, match, opts):
1390 1390 return repo.commit(message,
1391 1391 opts.get('user') or old.user(),
1392 1392 opts.get('date') or old.date(),
1393 1393 match,
1394 1394 extra=extra)
1395 1395
1396 1396 current = repo._bookmarkcurrent
1397 1397 marks = old.bookmarks()
1398 1398 node = cmdutil.amend(ui, repo, commitfunc, old, extra, pats, opts)
1399 1399 if node == old.node():
1400 1400 ui.status(_("nothing changed\n"))
1401 1401 return 1
1402 1402 elif marks:
1403 1403 ui.debug('moving bookmarks %r from %s to %s\n' %
1404 1404 (marks, old.hex(), hex(node)))
1405 1405 newmarks = repo._bookmarks
1406 1406 for bm in marks:
1407 1407 newmarks[bm] = node
1408 1408 if bm == current:
1409 1409 bookmarks.setcurrent(repo, bm)
1410 1410 newmarks.write()
1411 1411 else:
1412 1412 e = cmdutil.commiteditor
1413 1413 if forceeditor:
1414 1414 e = cmdutil.commitforceeditor
1415 1415
1416 1416 def commitfunc(ui, repo, message, match, opts):
1417 1417 try:
1418 1418 if opts.get('secret'):
1419 1419 ui.setconfig('phases', 'new-commit', 'secret', 'commit')
1420 1420 # Propagate to subrepos
1421 1421 repo.baseui.setconfig('phases', 'new-commit', 'secret',
1422 1422 'commit')
1423 1423
1424 1424 return repo.commit(message, opts.get('user'), opts.get('date'),
1425 1425 match, editor=e, extra=extra)
1426 1426 finally:
1427 1427 ui.setconfig('phases', 'new-commit', oldcommitphase, 'commit')
1428 1428 repo.baseui.setconfig('phases', 'new-commit', oldcommitphase,
1429 1429 'commit')
1430 1430
1431 1431
1432 1432 node = cmdutil.commit(ui, repo, commitfunc, pats, opts)
1433 1433
1434 1434 if not node:
1435 1435 stat = repo.status(match=scmutil.match(repo[None], pats, opts))
1436 1436 if stat[3]:
1437 1437 ui.status(_("nothing changed (%d missing files, see "
1438 1438 "'hg status')\n") % len(stat[3]))
1439 1439 else:
1440 1440 ui.status(_("nothing changed\n"))
1441 1441 return 1
1442 1442
1443 1443 cmdutil.commitstatus(repo, node, branch, bheads, opts)
1444 1444
1445 1445 @command('config|showconfig|debugconfig',
1446 1446 [('u', 'untrusted', None, _('show untrusted configuration options')),
1447 1447 ('e', 'edit', None, _('edit user config')),
1448 1448 ('l', 'local', None, _('edit repository config')),
1449 1449 ('g', 'global', None, _('edit global config'))],
1450 1450 _('[-u] [NAME]...'))
1451 1451 def config(ui, repo, *values, **opts):
1452 1452 """show combined config settings from all hgrc files
1453 1453
1454 1454 With no arguments, print names and values of all config items.
1455 1455
1456 1456 With one argument of the form section.name, print just the value
1457 1457 of that config item.
1458 1458
1459 1459 With multiple arguments, print names and values of all config
1460 1460 items with matching section names.
1461 1461
1462 1462 With --edit, start an editor on the user-level config file. With
1463 1463 --global, edit the system-wide config file. With --local, edit the
1464 1464 repository-level config file.
1465 1465
1466 1466 With --debug, the source (filename and line number) is printed
1467 1467 for each config item.
1468 1468
1469 1469 See :hg:`help config` for more information about config files.
1470 1470
1471 1471 Returns 0 on success.
1472 1472
1473 1473 """
1474 1474
1475 1475 if opts.get('edit') or opts.get('local') or opts.get('global'):
1476 1476 if opts.get('local') and opts.get('global'):
1477 1477 raise util.Abort(_("can't use --local and --global together"))
1478 1478
1479 1479 if opts.get('local'):
1480 1480 if not repo:
1481 1481 raise util.Abort(_("can't use --local outside a repository"))
1482 1482 paths = [repo.join('hgrc')]
1483 1483 elif opts.get('global'):
1484 1484 paths = scmutil.systemrcpath()
1485 1485 else:
1486 1486 paths = scmutil.userrcpath()
1487 1487
1488 1488 for f in paths:
1489 1489 if os.path.exists(f):
1490 1490 break
1491 1491 else:
1492 1492 f = paths[0]
1493 1493 fp = open(f, "w")
1494 1494 fp.write(
1495 1495 '# example config (see "hg help config" for more info)\n'
1496 1496 '\n'
1497 1497 '[ui]\n'
1498 1498 '# name and email, e.g.\n'
1499 1499 '# username = Jane Doe <jdoe@example.com>\n'
1500 1500 'username =\n'
1501 1501 '\n'
1502 1502 '[extensions]\n'
1503 1503 '# uncomment these lines to enable some popular extensions\n'
1504 1504 '# (see "hg help extensions" for more info)\n'
1505 1505 '# pager =\n'
1506 1506 '# progress =\n'
1507 1507 '# color =\n')
1508 1508 fp.close()
1509 1509
1510 1510 editor = ui.geteditor()
1511 1511 util.system("%s \"%s\"" % (editor, f),
1512 1512 onerr=util.Abort, errprefix=_("edit failed"),
1513 1513 out=ui.fout)
1514 1514 return
1515 1515
1516 1516 for f in scmutil.rcpath():
1517 1517 ui.debug('read config from: %s\n' % f)
1518 1518 untrusted = bool(opts.get('untrusted'))
1519 1519 if values:
1520 1520 sections = [v for v in values if '.' not in v]
1521 1521 items = [v for v in values if '.' in v]
1522 1522 if len(items) > 1 or items and sections:
1523 1523 raise util.Abort(_('only one config item permitted'))
1524 1524 for section, name, value in ui.walkconfig(untrusted=untrusted):
1525 1525 value = str(value).replace('\n', '\\n')
1526 1526 sectname = section + '.' + name
1527 1527 if values:
1528 1528 for v in values:
1529 1529 if v == section:
1530 1530 ui.debug('%s: ' %
1531 1531 ui.configsource(section, name, untrusted))
1532 1532 ui.write('%s=%s\n' % (sectname, value))
1533 1533 elif v == sectname:
1534 1534 ui.debug('%s: ' %
1535 1535 ui.configsource(section, name, untrusted))
1536 1536 ui.write(value, '\n')
1537 1537 else:
1538 1538 ui.debug('%s: ' %
1539 1539 ui.configsource(section, name, untrusted))
1540 1540 ui.write('%s=%s\n' % (sectname, value))
1541 1541
1542 1542 @command('copy|cp',
1543 1543 [('A', 'after', None, _('record a copy that has already occurred')),
1544 1544 ('f', 'force', None, _('forcibly copy over an existing managed file')),
1545 1545 ] + walkopts + dryrunopts,
1546 1546 _('[OPTION]... [SOURCE]... DEST'))
1547 1547 def copy(ui, repo, *pats, **opts):
1548 1548 """mark files as copied for the next commit
1549 1549
1550 1550 Mark dest as having copies of source files. If dest is a
1551 1551 directory, copies are put in that directory. If dest is a file,
1552 1552 the source must be a single file.
1553 1553
1554 1554 By default, this command copies the contents of files as they
1555 1555 exist in the working directory. If invoked with -A/--after, the
1556 1556 operation is recorded, but no copying is performed.
1557 1557
1558 1558 This command takes effect with the next commit. To undo a copy
1559 1559 before that, see :hg:`revert`.
1560 1560
1561 1561 Returns 0 on success, 1 if errors are encountered.
1562 1562 """
1563 1563 wlock = repo.wlock(False)
1564 1564 try:
1565 1565 return cmdutil.copy(ui, repo, pats, opts)
1566 1566 finally:
1567 1567 wlock.release()
1568 1568
1569 1569 @command('debugancestor', [], _('[INDEX] REV1 REV2'))
1570 1570 def debugancestor(ui, repo, *args):
1571 1571 """find the ancestor revision of two revisions in a given index"""
1572 1572 if len(args) == 3:
1573 1573 index, rev1, rev2 = args
1574 1574 r = revlog.revlog(scmutil.opener(os.getcwd(), audit=False), index)
1575 1575 lookup = r.lookup
1576 1576 elif len(args) == 2:
1577 1577 if not repo:
1578 1578 raise util.Abort(_("there is no Mercurial repository here "
1579 1579 "(.hg not found)"))
1580 1580 rev1, rev2 = args
1581 1581 r = repo.changelog
1582 1582 lookup = repo.lookup
1583 1583 else:
1584 1584 raise util.Abort(_('either two or three arguments required'))
1585 1585 a = r.ancestor(lookup(rev1), lookup(rev2))
1586 1586 ui.write("%d:%s\n" % (r.rev(a), hex(a)))
1587 1587
1588 1588 @command('debugbuilddag',
1589 1589 [('m', 'mergeable-file', None, _('add single file mergeable changes')),
1590 1590 ('o', 'overwritten-file', None, _('add single file all revs overwrite')),
1591 1591 ('n', 'new-file', None, _('add new file at each rev'))],
1592 1592 _('[OPTION]... [TEXT]'))
1593 1593 def debugbuilddag(ui, repo, text=None,
1594 1594 mergeable_file=False,
1595 1595 overwritten_file=False,
1596 1596 new_file=False):
1597 1597 """builds a repo with a given DAG from scratch in the current empty repo
1598 1598
1599 1599 The description of the DAG is read from stdin if not given on the
1600 1600 command line.
1601 1601
1602 1602 Elements:
1603 1603
1604 1604 - "+n" is a linear run of n nodes based on the current default parent
1605 1605 - "." is a single node based on the current default parent
1606 1606 - "$" resets the default parent to null (implied at the start);
1607 1607 otherwise the default parent is always the last node created
1608 1608 - "<p" sets the default parent to the backref p
1609 1609 - "*p" is a fork at parent p, which is a backref
1610 1610 - "*p1/p2" is a merge of parents p1 and p2, which are backrefs
1611 1611 - "/p2" is a merge of the preceding node and p2
1612 1612 - ":tag" defines a local tag for the preceding node
1613 1613 - "@branch" sets the named branch for subsequent nodes
1614 1614 - "#...\\n" is a comment up to the end of the line
1615 1615
1616 1616 Whitespace between the above elements is ignored.
1617 1617
1618 1618 A backref is either
1619 1619
1620 1620 - a number n, which references the node curr-n, where curr is the current
1621 1621 node, or
1622 1622 - the name of a local tag you placed earlier using ":tag", or
1623 1623 - empty to denote the default parent.
1624 1624
1625 1625 All string valued-elements are either strictly alphanumeric, or must
1626 1626 be enclosed in double quotes ("..."), with "\\" as escape character.
1627 1627 """
1628 1628
1629 1629 if text is None:
1630 1630 ui.status(_("reading DAG from stdin\n"))
1631 1631 text = ui.fin.read()
1632 1632
1633 1633 cl = repo.changelog
1634 1634 if len(cl) > 0:
1635 1635 raise util.Abort(_('repository is not empty'))
1636 1636
1637 1637 # determine number of revs in DAG
1638 1638 total = 0
1639 1639 for type, data in dagparser.parsedag(text):
1640 1640 if type == 'n':
1641 1641 total += 1
1642 1642
1643 1643 if mergeable_file:
1644 1644 linesperrev = 2
1645 1645 # make a file with k lines per rev
1646 1646 initialmergedlines = [str(i) for i in xrange(0, total * linesperrev)]
1647 1647 initialmergedlines.append("")
1648 1648
1649 1649 tags = []
1650 1650
1651 1651 lock = tr = None
1652 1652 try:
1653 1653 lock = repo.lock()
1654 1654 tr = repo.transaction("builddag")
1655 1655
1656 1656 at = -1
1657 1657 atbranch = 'default'
1658 1658 nodeids = []
1659 1659 id = 0
1660 1660 ui.progress(_('building'), id, unit=_('revisions'), total=total)
1661 1661 for type, data in dagparser.parsedag(text):
1662 1662 if type == 'n':
1663 1663 ui.note(('node %s\n' % str(data)))
1664 1664 id, ps = data
1665 1665
1666 1666 files = []
1667 1667 fctxs = {}
1668 1668
1669 1669 p2 = None
1670 1670 if mergeable_file:
1671 1671 fn = "mf"
1672 1672 p1 = repo[ps[0]]
1673 1673 if len(ps) > 1:
1674 1674 p2 = repo[ps[1]]
1675 1675 pa = p1.ancestor(p2)
1676 1676 base, local, other = [x[fn].data() for x in (pa, p1,
1677 1677 p2)]
1678 1678 m3 = simplemerge.Merge3Text(base, local, other)
1679 1679 ml = [l.strip() for l in m3.merge_lines()]
1680 1680 ml.append("")
1681 1681 elif at > 0:
1682 1682 ml = p1[fn].data().split("\n")
1683 1683 else:
1684 1684 ml = initialmergedlines
1685 1685 ml[id * linesperrev] += " r%i" % id
1686 1686 mergedtext = "\n".join(ml)
1687 1687 files.append(fn)
1688 1688 fctxs[fn] = context.memfilectx(fn, mergedtext)
1689 1689
1690 1690 if overwritten_file:
1691 1691 fn = "of"
1692 1692 files.append(fn)
1693 1693 fctxs[fn] = context.memfilectx(fn, "r%i\n" % id)
1694 1694
1695 1695 if new_file:
1696 1696 fn = "nf%i" % id
1697 1697 files.append(fn)
1698 1698 fctxs[fn] = context.memfilectx(fn, "r%i\n" % id)
1699 1699 if len(ps) > 1:
1700 1700 if not p2:
1701 1701 p2 = repo[ps[1]]
1702 1702 for fn in p2:
1703 1703 if fn.startswith("nf"):
1704 1704 files.append(fn)
1705 1705 fctxs[fn] = p2[fn]
1706 1706
1707 1707 def fctxfn(repo, cx, path):
1708 1708 return fctxs.get(path)
1709 1709
1710 1710 if len(ps) == 0 or ps[0] < 0:
1711 1711 pars = [None, None]
1712 1712 elif len(ps) == 1:
1713 1713 pars = [nodeids[ps[0]], None]
1714 1714 else:
1715 1715 pars = [nodeids[p] for p in ps]
1716 1716 cx = context.memctx(repo, pars, "r%i" % id, files, fctxfn,
1717 1717 date=(id, 0),
1718 1718 user="debugbuilddag",
1719 1719 extra={'branch': atbranch})
1720 1720 nodeid = repo.commitctx(cx)
1721 1721 nodeids.append(nodeid)
1722 1722 at = id
1723 1723 elif type == 'l':
1724 1724 id, name = data
1725 1725 ui.note(('tag %s\n' % name))
1726 1726 tags.append("%s %s\n" % (hex(repo.changelog.node(id)), name))
1727 1727 elif type == 'a':
1728 1728 ui.note(('branch %s\n' % data))
1729 1729 atbranch = data
1730 1730 ui.progress(_('building'), id, unit=_('revisions'), total=total)
1731 1731 tr.close()
1732 1732
1733 1733 if tags:
1734 1734 repo.opener.write("localtags", "".join(tags))
1735 1735 finally:
1736 1736 ui.progress(_('building'), None)
1737 1737 release(tr, lock)
1738 1738
1739 1739 @command('debugbundle', [('a', 'all', None, _('show all details'))], _('FILE'))
1740 1740 def debugbundle(ui, bundlepath, all=None, **opts):
1741 1741 """lists the contents of a bundle"""
1742 1742 f = hg.openpath(ui, bundlepath)
1743 1743 try:
1744 1744 gen = exchange.readbundle(ui, f, bundlepath)
1745 1745 if all:
1746 1746 ui.write(("format: id, p1, p2, cset, delta base, len(delta)\n"))
1747 1747
1748 1748 def showchunks(named):
1749 1749 ui.write("\n%s\n" % named)
1750 1750 chain = None
1751 1751 while True:
1752 1752 chunkdata = gen.deltachunk(chain)
1753 1753 if not chunkdata:
1754 1754 break
1755 1755 node = chunkdata['node']
1756 1756 p1 = chunkdata['p1']
1757 1757 p2 = chunkdata['p2']
1758 1758 cs = chunkdata['cs']
1759 1759 deltabase = chunkdata['deltabase']
1760 1760 delta = chunkdata['delta']
1761 1761 ui.write("%s %s %s %s %s %s\n" %
1762 1762 (hex(node), hex(p1), hex(p2),
1763 1763 hex(cs), hex(deltabase), len(delta)))
1764 1764 chain = node
1765 1765
1766 1766 chunkdata = gen.changelogheader()
1767 1767 showchunks("changelog")
1768 1768 chunkdata = gen.manifestheader()
1769 1769 showchunks("manifest")
1770 1770 while True:
1771 1771 chunkdata = gen.filelogheader()
1772 1772 if not chunkdata:
1773 1773 break
1774 1774 fname = chunkdata['filename']
1775 1775 showchunks(fname)
1776 1776 else:
1777 1777 chunkdata = gen.changelogheader()
1778 1778 chain = None
1779 1779 while True:
1780 1780 chunkdata = gen.deltachunk(chain)
1781 1781 if not chunkdata:
1782 1782 break
1783 1783 node = chunkdata['node']
1784 1784 ui.write("%s\n" % hex(node))
1785 1785 chain = node
1786 1786 finally:
1787 1787 f.close()
1788 1788
1789 1789 @command('debugcheckstate', [], '')
1790 1790 def debugcheckstate(ui, repo):
1791 1791 """validate the correctness of the current dirstate"""
1792 1792 parent1, parent2 = repo.dirstate.parents()
1793 1793 m1 = repo[parent1].manifest()
1794 1794 m2 = repo[parent2].manifest()
1795 1795 errors = 0
1796 1796 for f in repo.dirstate:
1797 1797 state = repo.dirstate[f]
1798 1798 if state in "nr" and f not in m1:
1799 1799 ui.warn(_("%s in state %s, but not in manifest1\n") % (f, state))
1800 1800 errors += 1
1801 1801 if state in "a" and f in m1:
1802 1802 ui.warn(_("%s in state %s, but also in manifest1\n") % (f, state))
1803 1803 errors += 1
1804 1804 if state in "m" and f not in m1 and f not in m2:
1805 1805 ui.warn(_("%s in state %s, but not in either manifest\n") %
1806 1806 (f, state))
1807 1807 errors += 1
1808 1808 for f in m1:
1809 1809 state = repo.dirstate[f]
1810 1810 if state not in "nrm":
1811 1811 ui.warn(_("%s in manifest1, but listed as state %s") % (f, state))
1812 1812 errors += 1
1813 1813 if errors:
1814 1814 error = _(".hg/dirstate inconsistent with current parent's manifest")
1815 1815 raise util.Abort(error)
1816 1816
1817 1817 @command('debugcommands', [], _('[COMMAND]'))
1818 1818 def debugcommands(ui, cmd='', *args):
1819 1819 """list all available commands and options"""
1820 1820 for cmd, vals in sorted(table.iteritems()):
1821 1821 cmd = cmd.split('|')[0].strip('^')
1822 1822 opts = ', '.join([i[1] for i in vals[1]])
1823 1823 ui.write('%s: %s\n' % (cmd, opts))
1824 1824
1825 1825 @command('debugcomplete',
1826 1826 [('o', 'options', None, _('show the command options'))],
1827 1827 _('[-o] CMD'))
1828 1828 def debugcomplete(ui, cmd='', **opts):
1829 1829 """returns the completion list associated with the given command"""
1830 1830
1831 1831 if opts.get('options'):
1832 1832 options = []
1833 1833 otables = [globalopts]
1834 1834 if cmd:
1835 1835 aliases, entry = cmdutil.findcmd(cmd, table, False)
1836 1836 otables.append(entry[1])
1837 1837 for t in otables:
1838 1838 for o in t:
1839 1839 if "(DEPRECATED)" in o[3]:
1840 1840 continue
1841 1841 if o[0]:
1842 1842 options.append('-%s' % o[0])
1843 1843 options.append('--%s' % o[1])
1844 1844 ui.write("%s\n" % "\n".join(options))
1845 1845 return
1846 1846
1847 1847 cmdlist = cmdutil.findpossible(cmd, table)
1848 1848 if ui.verbose:
1849 1849 cmdlist = [' '.join(c[0]) for c in cmdlist.values()]
1850 1850 ui.write("%s\n" % "\n".join(sorted(cmdlist)))
1851 1851
1852 1852 @command('debugdag',
1853 1853 [('t', 'tags', None, _('use tags as labels')),
1854 1854 ('b', 'branches', None, _('annotate with branch names')),
1855 1855 ('', 'dots', None, _('use dots for runs')),
1856 1856 ('s', 'spaces', None, _('separate elements by spaces'))],
1857 1857 _('[OPTION]... [FILE [REV]...]'))
1858 1858 def debugdag(ui, repo, file_=None, *revs, **opts):
1859 1859 """format the changelog or an index DAG as a concise textual description
1860 1860
1861 1861 If you pass a revlog index, the revlog's DAG is emitted. If you list
1862 1862 revision numbers, they get labeled in the output as rN.
1863 1863
1864 1864 Otherwise, the changelog DAG of the current repo is emitted.
1865 1865 """
1866 1866 spaces = opts.get('spaces')
1867 1867 dots = opts.get('dots')
1868 1868 if file_:
1869 1869 rlog = revlog.revlog(scmutil.opener(os.getcwd(), audit=False), file_)
1870 1870 revs = set((int(r) for r in revs))
1871 1871 def events():
1872 1872 for r in rlog:
1873 1873 yield 'n', (r, list(set(p for p in rlog.parentrevs(r)
1874 1874 if p != -1)))
1875 1875 if r in revs:
1876 1876 yield 'l', (r, "r%i" % r)
1877 1877 elif repo:
1878 1878 cl = repo.changelog
1879 1879 tags = opts.get('tags')
1880 1880 branches = opts.get('branches')
1881 1881 if tags:
1882 1882 labels = {}
1883 1883 for l, n in repo.tags().items():
1884 1884 labels.setdefault(cl.rev(n), []).append(l)
1885 1885 def events():
1886 1886 b = "default"
1887 1887 for r in cl:
1888 1888 if branches:
1889 1889 newb = cl.read(cl.node(r))[5]['branch']
1890 1890 if newb != b:
1891 1891 yield 'a', newb
1892 1892 b = newb
1893 1893 yield 'n', (r, list(set(p for p in cl.parentrevs(r)
1894 1894 if p != -1)))
1895 1895 if tags:
1896 1896 ls = labels.get(r)
1897 1897 if ls:
1898 1898 for l in ls:
1899 1899 yield 'l', (r, l)
1900 1900 else:
1901 1901 raise util.Abort(_('need repo for changelog dag'))
1902 1902
1903 1903 for line in dagparser.dagtextlines(events(),
1904 1904 addspaces=spaces,
1905 1905 wraplabels=True,
1906 1906 wrapannotations=True,
1907 1907 wrapnonlinear=dots,
1908 1908 usedots=dots,
1909 1909 maxlinewidth=70):
1910 1910 ui.write(line)
1911 1911 ui.write("\n")
1912 1912
1913 1913 @command('debugdata',
1914 1914 [('c', 'changelog', False, _('open changelog')),
1915 1915 ('m', 'manifest', False, _('open manifest'))],
1916 1916 _('-c|-m|FILE REV'))
1917 1917 def debugdata(ui, repo, file_, rev=None, **opts):
1918 1918 """dump the contents of a data file revision"""
1919 1919 if opts.get('changelog') or opts.get('manifest'):
1920 1920 file_, rev = None, file_
1921 1921 elif rev is None:
1922 1922 raise error.CommandError('debugdata', _('invalid arguments'))
1923 1923 r = cmdutil.openrevlog(repo, 'debugdata', file_, opts)
1924 1924 try:
1925 1925 ui.write(r.revision(r.lookup(rev)))
1926 1926 except KeyError:
1927 1927 raise util.Abort(_('invalid revision identifier %s') % rev)
1928 1928
1929 1929 @command('debugdate',
1930 1930 [('e', 'extended', None, _('try extended date formats'))],
1931 1931 _('[-e] DATE [RANGE]'))
1932 1932 def debugdate(ui, date, range=None, **opts):
1933 1933 """parse and display a date"""
1934 1934 if opts["extended"]:
1935 1935 d = util.parsedate(date, util.extendeddateformats)
1936 1936 else:
1937 1937 d = util.parsedate(date)
1938 1938 ui.write(("internal: %s %s\n") % d)
1939 1939 ui.write(("standard: %s\n") % util.datestr(d))
1940 1940 if range:
1941 1941 m = util.matchdate(range)
1942 1942 ui.write(("match: %s\n") % m(d[0]))
1943 1943
1944 1944 @command('debugdiscovery',
1945 1945 [('', 'old', None, _('use old-style discovery')),
1946 1946 ('', 'nonheads', None,
1947 1947 _('use old-style discovery with non-heads included')),
1948 1948 ] + remoteopts,
1949 1949 _('[-l REV] [-r REV] [-b BRANCH]... [OTHER]'))
1950 1950 def debugdiscovery(ui, repo, remoteurl="default", **opts):
1951 1951 """runs the changeset discovery protocol in isolation"""
1952 1952 remoteurl, branches = hg.parseurl(ui.expandpath(remoteurl),
1953 1953 opts.get('branch'))
1954 1954 remote = hg.peer(repo, opts, remoteurl)
1955 1955 ui.status(_('comparing with %s\n') % util.hidepassword(remoteurl))
1956 1956
1957 1957 # make sure tests are repeatable
1958 1958 random.seed(12323)
1959 1959
1960 1960 def doit(localheads, remoteheads, remote=remote):
1961 1961 if opts.get('old'):
1962 1962 if localheads:
1963 1963 raise util.Abort('cannot use localheads with old style '
1964 1964 'discovery')
1965 1965 if not util.safehasattr(remote, 'branches'):
1966 1966 # enable in-client legacy support
1967 1967 remote = localrepo.locallegacypeer(remote.local())
1968 1968 common, _in, hds = treediscovery.findcommonincoming(repo, remote,
1969 1969 force=True)
1970 1970 common = set(common)
1971 1971 if not opts.get('nonheads'):
1972 1972 ui.write(("unpruned common: %s\n") %
1973 1973 " ".join(sorted(short(n) for n in common)))
1974 1974 dag = dagutil.revlogdag(repo.changelog)
1975 1975 all = dag.ancestorset(dag.internalizeall(common))
1976 1976 common = dag.externalizeall(dag.headsetofconnecteds(all))
1977 1977 else:
1978 1978 common, any, hds = setdiscovery.findcommonheads(ui, repo, remote)
1979 1979 common = set(common)
1980 1980 rheads = set(hds)
1981 1981 lheads = set(repo.heads())
1982 1982 ui.write(("common heads: %s\n") %
1983 1983 " ".join(sorted(short(n) for n in common)))
1984 1984 if lheads <= common:
1985 1985 ui.write(("local is subset\n"))
1986 1986 elif rheads <= common:
1987 1987 ui.write(("remote is subset\n"))
1988 1988
1989 1989 serverlogs = opts.get('serverlog')
1990 1990 if serverlogs:
1991 1991 for filename in serverlogs:
1992 1992 logfile = open(filename, 'r')
1993 1993 try:
1994 1994 line = logfile.readline()
1995 1995 while line:
1996 1996 parts = line.strip().split(';')
1997 1997 op = parts[1]
1998 1998 if op == 'cg':
1999 1999 pass
2000 2000 elif op == 'cgss':
2001 2001 doit(parts[2].split(' '), parts[3].split(' '))
2002 2002 elif op == 'unb':
2003 2003 doit(parts[3].split(' '), parts[2].split(' '))
2004 2004 line = logfile.readline()
2005 2005 finally:
2006 2006 logfile.close()
2007 2007
2008 2008 else:
2009 2009 remoterevs, _checkout = hg.addbranchrevs(repo, remote, branches,
2010 2010 opts.get('remote_head'))
2011 2011 localrevs = opts.get('local_head')
2012 2012 doit(localrevs, remoterevs)
2013 2013
2014 2014 @command('debugfileset',
2015 2015 [('r', 'rev', '', _('apply the filespec on this revision'), _('REV'))],
2016 2016 _('[-r REV] FILESPEC'))
2017 2017 def debugfileset(ui, repo, expr, **opts):
2018 2018 '''parse and apply a fileset specification'''
2019 2019 ctx = scmutil.revsingle(repo, opts.get('rev'), None)
2020 2020 if ui.verbose:
2021 2021 tree = fileset.parse(expr)[0]
2022 2022 ui.note(tree, "\n")
2023 2023
2024 2024 for f in ctx.getfileset(expr):
2025 2025 ui.write("%s\n" % f)
2026 2026
2027 2027 @command('debugfsinfo', [], _('[PATH]'))
2028 2028 def debugfsinfo(ui, path="."):
2029 2029 """show information detected about current filesystem"""
2030 2030 util.writefile('.debugfsinfo', '')
2031 2031 ui.write(('exec: %s\n') % (util.checkexec(path) and 'yes' or 'no'))
2032 2032 ui.write(('symlink: %s\n') % (util.checklink(path) and 'yes' or 'no'))
2033 2033 ui.write(('hardlink: %s\n') % (util.checknlink(path) and 'yes' or 'no'))
2034 2034 ui.write(('case-sensitive: %s\n') % (util.checkcase('.debugfsinfo')
2035 2035 and 'yes' or 'no'))
2036 2036 os.unlink('.debugfsinfo')
2037 2037
2038 2038 @command('debuggetbundle',
2039 2039 [('H', 'head', [], _('id of head node'), _('ID')),
2040 2040 ('C', 'common', [], _('id of common node'), _('ID')),
2041 2041 ('t', 'type', 'bzip2', _('bundle compression type to use'), _('TYPE'))],
2042 2042 _('REPO FILE [-H|-C ID]...'))
2043 2043 def debuggetbundle(ui, repopath, bundlepath, head=None, common=None, **opts):
2044 2044 """retrieves a bundle from a repo
2045 2045
2046 2046 Every ID must be a full-length hex node id string. Saves the bundle to the
2047 2047 given file.
2048 2048 """
2049 2049 repo = hg.peer(ui, opts, repopath)
2050 2050 if not repo.capable('getbundle'):
2051 2051 raise util.Abort("getbundle() not supported by target repository")
2052 2052 args = {}
2053 2053 if common:
2054 2054 args['common'] = [bin(s) for s in common]
2055 2055 if head:
2056 2056 args['heads'] = [bin(s) for s in head]
2057 2057 # TODO: get desired bundlecaps from command line.
2058 2058 args['bundlecaps'] = None
2059 2059 bundle = repo.getbundle('debug', **args)
2060 2060
2061 2061 bundletype = opts.get('type', 'bzip2').lower()
2062 2062 btypes = {'none': 'HG10UN', 'bzip2': 'HG10BZ', 'gzip': 'HG10GZ'}
2063 2063 bundletype = btypes.get(bundletype)
2064 2064 if bundletype not in changegroup.bundletypes:
2065 2065 raise util.Abort(_('unknown bundle type specified with --type'))
2066 2066 changegroup.writebundle(bundle, bundlepath, bundletype)
2067 2067
2068 2068 @command('debugignore', [], '')
2069 2069 def debugignore(ui, repo, *values, **opts):
2070 2070 """display the combined ignore pattern"""
2071 2071 ignore = repo.dirstate._ignore
2072 2072 includepat = getattr(ignore, 'includepat', None)
2073 2073 if includepat is not None:
2074 2074 ui.write("%s\n" % includepat)
2075 2075 else:
2076 2076 raise util.Abort(_("no ignore patterns found"))
2077 2077
2078 2078 @command('debugindex',
2079 2079 [('c', 'changelog', False, _('open changelog')),
2080 2080 ('m', 'manifest', False, _('open manifest')),
2081 2081 ('f', 'format', 0, _('revlog format'), _('FORMAT'))],
2082 2082 _('[-f FORMAT] -c|-m|FILE'))
2083 2083 def debugindex(ui, repo, file_=None, **opts):
2084 2084 """dump the contents of an index file"""
2085 2085 r = cmdutil.openrevlog(repo, 'debugindex', file_, opts)
2086 2086 format = opts.get('format', 0)
2087 2087 if format not in (0, 1):
2088 2088 raise util.Abort(_("unknown format %d") % format)
2089 2089
2090 2090 generaldelta = r.version & revlog.REVLOGGENERALDELTA
2091 2091 if generaldelta:
2092 2092 basehdr = ' delta'
2093 2093 else:
2094 2094 basehdr = ' base'
2095 2095
2096 2096 if format == 0:
2097 2097 ui.write(" rev offset length " + basehdr + " linkrev"
2098 2098 " nodeid p1 p2\n")
2099 2099 elif format == 1:
2100 2100 ui.write(" rev flag offset length"
2101 2101 " size " + basehdr + " link p1 p2"
2102 2102 " nodeid\n")
2103 2103
2104 2104 for i in r:
2105 2105 node = r.node(i)
2106 2106 if generaldelta:
2107 2107 base = r.deltaparent(i)
2108 2108 else:
2109 2109 base = r.chainbase(i)
2110 2110 if format == 0:
2111 2111 try:
2112 2112 pp = r.parents(node)
2113 2113 except Exception:
2114 2114 pp = [nullid, nullid]
2115 2115 ui.write("% 6d % 9d % 7d % 6d % 7d %s %s %s\n" % (
2116 2116 i, r.start(i), r.length(i), base, r.linkrev(i),
2117 2117 short(node), short(pp[0]), short(pp[1])))
2118 2118 elif format == 1:
2119 2119 pr = r.parentrevs(i)
2120 2120 ui.write("% 6d %04x % 8d % 8d % 8d % 6d % 6d % 6d % 6d %s\n" % (
2121 2121 i, r.flags(i), r.start(i), r.length(i), r.rawsize(i),
2122 2122 base, r.linkrev(i), pr[0], pr[1], short(node)))
2123 2123
2124 2124 @command('debugindexdot', [], _('FILE'))
2125 2125 def debugindexdot(ui, repo, file_):
2126 2126 """dump an index DAG as a graphviz dot file"""
2127 2127 r = None
2128 2128 if repo:
2129 2129 filelog = repo.file(file_)
2130 2130 if len(filelog):
2131 2131 r = filelog
2132 2132 if not r:
2133 2133 r = revlog.revlog(scmutil.opener(os.getcwd(), audit=False), file_)
2134 2134 ui.write(("digraph G {\n"))
2135 2135 for i in r:
2136 2136 node = r.node(i)
2137 2137 pp = r.parents(node)
2138 2138 ui.write("\t%d -> %d\n" % (r.rev(pp[0]), i))
2139 2139 if pp[1] != nullid:
2140 2140 ui.write("\t%d -> %d\n" % (r.rev(pp[1]), i))
2141 2141 ui.write("}\n")
2142 2142
2143 2143 @command('debuginstall', [], '')
2144 2144 def debuginstall(ui):
2145 2145 '''test Mercurial installation
2146 2146
2147 2147 Returns 0 on success.
2148 2148 '''
2149 2149
2150 2150 def writetemp(contents):
2151 2151 (fd, name) = tempfile.mkstemp(prefix="hg-debuginstall-")
2152 2152 f = os.fdopen(fd, "wb")
2153 2153 f.write(contents)
2154 2154 f.close()
2155 2155 return name
2156 2156
2157 2157 problems = 0
2158 2158
2159 2159 # encoding
2160 2160 ui.status(_("checking encoding (%s)...\n") % encoding.encoding)
2161 2161 try:
2162 2162 encoding.fromlocal("test")
2163 2163 except util.Abort, inst:
2164 2164 ui.write(" %s\n" % inst)
2165 2165 ui.write(_(" (check that your locale is properly set)\n"))
2166 2166 problems += 1
2167 2167
2168 2168 # Python
2169 2169 ui.status(_("checking Python executable (%s)\n") % sys.executable)
2170 2170 ui.status(_("checking Python version (%s)\n")
2171 2171 % ("%s.%s.%s" % sys.version_info[:3]))
2172 2172 ui.status(_("checking Python lib (%s)...\n")
2173 2173 % os.path.dirname(os.__file__))
2174 2174
2175 2175 # compiled modules
2176 2176 ui.status(_("checking installed modules (%s)...\n")
2177 2177 % os.path.dirname(__file__))
2178 2178 try:
2179 2179 import bdiff, mpatch, base85, osutil
2180 2180 dir(bdiff), dir(mpatch), dir(base85), dir(osutil) # quiet pyflakes
2181 2181 except Exception, inst:
2182 2182 ui.write(" %s\n" % inst)
2183 2183 ui.write(_(" One or more extensions could not be found"))
2184 2184 ui.write(_(" (check that you compiled the extensions)\n"))
2185 2185 problems += 1
2186 2186
2187 2187 # templates
2188 2188 import templater
2189 2189 p = templater.templatepath()
2190 2190 ui.status(_("checking templates (%s)...\n") % ' '.join(p))
2191 2191 if p:
2192 2192 m = templater.templatepath("map-cmdline.default")
2193 2193 if m:
2194 2194 # template found, check if it is working
2195 2195 try:
2196 2196 templater.templater(m)
2197 2197 except Exception, inst:
2198 2198 ui.write(" %s\n" % inst)
2199 2199 p = None
2200 2200 else:
2201 2201 ui.write(_(" template 'default' not found\n"))
2202 2202 p = None
2203 2203 else:
2204 2204 ui.write(_(" no template directories found\n"))
2205 2205 if not p:
2206 2206 ui.write(_(" (templates seem to have been installed incorrectly)\n"))
2207 2207 problems += 1
2208 2208
2209 2209 # editor
2210 2210 ui.status(_("checking commit editor...\n"))
2211 2211 editor = ui.geteditor()
2212 2212 cmdpath = util.findexe(editor) or util.findexe(editor.split()[0])
2213 2213 if not cmdpath:
2214 2214 if editor == 'vi':
2215 2215 ui.write(_(" No commit editor set and can't find vi in PATH\n"))
2216 2216 ui.write(_(" (specify a commit editor in your configuration"
2217 2217 " file)\n"))
2218 2218 else:
2219 2219 ui.write(_(" Can't find editor '%s' in PATH\n") % editor)
2220 2220 ui.write(_(" (specify a commit editor in your configuration"
2221 2221 " file)\n"))
2222 2222 problems += 1
2223 2223
2224 2224 # check username
2225 2225 ui.status(_("checking username...\n"))
2226 2226 try:
2227 2227 ui.username()
2228 2228 except util.Abort, e:
2229 2229 ui.write(" %s\n" % e)
2230 2230 ui.write(_(" (specify a username in your configuration file)\n"))
2231 2231 problems += 1
2232 2232
2233 2233 if not problems:
2234 2234 ui.status(_("no problems detected\n"))
2235 2235 else:
2236 2236 ui.write(_("%s problems detected,"
2237 2237 " please check your install!\n") % problems)
2238 2238
2239 2239 return problems
2240 2240
2241 2241 @command('debugknown', [], _('REPO ID...'))
2242 2242 def debugknown(ui, repopath, *ids, **opts):
2243 2243 """test whether node ids are known to a repo
2244 2244
2245 2245 Every ID must be a full-length hex node id string. Returns a list of 0s
2246 2246 and 1s indicating unknown/known.
2247 2247 """
2248 2248 repo = hg.peer(ui, opts, repopath)
2249 2249 if not repo.capable('known'):
2250 2250 raise util.Abort("known() not supported by target repository")
2251 2251 flags = repo.known([bin(s) for s in ids])
2252 2252 ui.write("%s\n" % ("".join([f and "1" or "0" for f in flags])))
2253 2253
2254 2254 @command('debuglabelcomplete', [], _('LABEL...'))
2255 2255 def debuglabelcomplete(ui, repo, *args):
2256 2256 '''complete "labels" - tags, open branch names, bookmark names'''
2257 2257
2258 2258 labels = set()
2259 2259 labels.update(t[0] for t in repo.tagslist())
2260 2260 labels.update(repo._bookmarks.keys())
2261 2261 labels.update(tag for (tag, heads, tip, closed)
2262 2262 in repo.branchmap().iterbranches() if not closed)
2263 2263 completions = set()
2264 2264 if not args:
2265 2265 args = ['']
2266 2266 for a in args:
2267 2267 completions.update(l for l in labels if l.startswith(a))
2268 2268 ui.write('\n'.join(sorted(completions)))
2269 2269 ui.write('\n')
2270 2270
2271 2271 @command('debugobsolete',
2272 2272 [('', 'flags', 0, _('markers flag')),
2273 2273 ] + commitopts2,
2274 2274 _('[OBSOLETED [REPLACEMENT] [REPL... ]'))
2275 2275 def debugobsolete(ui, repo, precursor=None, *successors, **opts):
2276 2276 """create arbitrary obsolete marker
2277 2277
2278 2278 With no arguments, displays the list of obsolescence markers."""
2279 2279 def parsenodeid(s):
2280 2280 try:
2281 2281 # We do not use revsingle/revrange functions here to accept
2282 2282 # arbitrary node identifiers, possibly not present in the
2283 2283 # local repository.
2284 2284 n = bin(s)
2285 2285 if len(n) != len(nullid):
2286 2286 raise TypeError()
2287 2287 return n
2288 2288 except TypeError:
2289 2289 raise util.Abort('changeset references must be full hexadecimal '
2290 2290 'node identifiers')
2291 2291
2292 2292 if precursor is not None:
2293 2293 metadata = {}
2294 2294 if 'date' in opts:
2295 2295 metadata['date'] = opts['date']
2296 2296 metadata['user'] = opts['user'] or ui.username()
2297 2297 succs = tuple(parsenodeid(succ) for succ in successors)
2298 2298 l = repo.lock()
2299 2299 try:
2300 2300 tr = repo.transaction('debugobsolete')
2301 2301 try:
2302 2302 repo.obsstore.create(tr, parsenodeid(precursor), succs,
2303 2303 opts['flags'], metadata)
2304 2304 tr.close()
2305 2305 finally:
2306 2306 tr.release()
2307 2307 finally:
2308 2308 l.release()
2309 2309 else:
2310 2310 for m in obsolete.allmarkers(repo):
2311 2311 cmdutil.showmarker(ui, m)
2312 2312
2313 2313 @command('debugpathcomplete',
2314 2314 [('f', 'full', None, _('complete an entire path')),
2315 2315 ('n', 'normal', None, _('show only normal files')),
2316 2316 ('a', 'added', None, _('show only added files')),
2317 2317 ('r', 'removed', None, _('show only removed files'))],
2318 2318 _('FILESPEC...'))
2319 2319 def debugpathcomplete(ui, repo, *specs, **opts):
2320 2320 '''complete part or all of a tracked path
2321 2321
2322 2322 This command supports shells that offer path name completion. It
2323 2323 currently completes only files already known to the dirstate.
2324 2324
2325 2325 Completion extends only to the next path segment unless
2326 2326 --full is specified, in which case entire paths are used.'''
2327 2327
2328 2328 def complete(path, acceptable):
2329 2329 dirstate = repo.dirstate
2330 2330 spec = os.path.normpath(os.path.join(os.getcwd(), path))
2331 2331 rootdir = repo.root + os.sep
2332 2332 if spec != repo.root and not spec.startswith(rootdir):
2333 2333 return [], []
2334 2334 if os.path.isdir(spec):
2335 2335 spec += '/'
2336 2336 spec = spec[len(rootdir):]
2337 2337 fixpaths = os.sep != '/'
2338 2338 if fixpaths:
2339 2339 spec = spec.replace(os.sep, '/')
2340 2340 speclen = len(spec)
2341 2341 fullpaths = opts['full']
2342 2342 files, dirs = set(), set()
2343 2343 adddir, addfile = dirs.add, files.add
2344 2344 for f, st in dirstate.iteritems():
2345 2345 if f.startswith(spec) and st[0] in acceptable:
2346 2346 if fixpaths:
2347 2347 f = f.replace('/', os.sep)
2348 2348 if fullpaths:
2349 2349 addfile(f)
2350 2350 continue
2351 2351 s = f.find(os.sep, speclen)
2352 2352 if s >= 0:
2353 2353 adddir(f[:s])
2354 2354 else:
2355 2355 addfile(f)
2356 2356 return files, dirs
2357 2357
2358 2358 acceptable = ''
2359 2359 if opts['normal']:
2360 2360 acceptable += 'nm'
2361 2361 if opts['added']:
2362 2362 acceptable += 'a'
2363 2363 if opts['removed']:
2364 2364 acceptable += 'r'
2365 2365 cwd = repo.getcwd()
2366 2366 if not specs:
2367 2367 specs = ['.']
2368 2368
2369 2369 files, dirs = set(), set()
2370 2370 for spec in specs:
2371 2371 f, d = complete(spec, acceptable or 'nmar')
2372 2372 files.update(f)
2373 2373 dirs.update(d)
2374 2374 files.update(dirs)
2375 2375 ui.write('\n'.join(repo.pathto(p, cwd) for p in sorted(files)))
2376 2376 ui.write('\n')
2377 2377
2378 2378 @command('debugpushkey', [], _('REPO NAMESPACE [KEY OLD NEW]'))
2379 2379 def debugpushkey(ui, repopath, namespace, *keyinfo, **opts):
2380 2380 '''access the pushkey key/value protocol
2381 2381
2382 2382 With two args, list the keys in the given namespace.
2383 2383
2384 2384 With five args, set a key to new if it currently is set to old.
2385 2385 Reports success or failure.
2386 2386 '''
2387 2387
2388 2388 target = hg.peer(ui, {}, repopath)
2389 2389 if keyinfo:
2390 2390 key, old, new = keyinfo
2391 2391 r = target.pushkey(namespace, key, old, new)
2392 2392 ui.status(str(r) + '\n')
2393 2393 return not r
2394 2394 else:
2395 2395 for k, v in sorted(target.listkeys(namespace).iteritems()):
2396 2396 ui.write("%s\t%s\n" % (k.encode('string-escape'),
2397 2397 v.encode('string-escape')))
2398 2398
2399 2399 @command('debugpvec', [], _('A B'))
2400 2400 def debugpvec(ui, repo, a, b=None):
2401 2401 ca = scmutil.revsingle(repo, a)
2402 2402 cb = scmutil.revsingle(repo, b)
2403 2403 pa = pvec.ctxpvec(ca)
2404 2404 pb = pvec.ctxpvec(cb)
2405 2405 if pa == pb:
2406 2406 rel = "="
2407 2407 elif pa > pb:
2408 2408 rel = ">"
2409 2409 elif pa < pb:
2410 2410 rel = "<"
2411 2411 elif pa | pb:
2412 2412 rel = "|"
2413 2413 ui.write(_("a: %s\n") % pa)
2414 2414 ui.write(_("b: %s\n") % pb)
2415 2415 ui.write(_("depth(a): %d depth(b): %d\n") % (pa._depth, pb._depth))
2416 2416 ui.write(_("delta: %d hdist: %d distance: %d relation: %s\n") %
2417 2417 (abs(pa._depth - pb._depth), pvec._hamming(pa._vec, pb._vec),
2418 2418 pa.distance(pb), rel))
2419 2419
2420 2420 @command('debugrebuilddirstate|debugrebuildstate',
2421 2421 [('r', 'rev', '', _('revision to rebuild to'), _('REV'))],
2422 2422 _('[-r REV]'))
2423 2423 def debugrebuilddirstate(ui, repo, rev):
2424 2424 """rebuild the dirstate as it would look like for the given revision
2425 2425
2426 2426 If no revision is specified the first current parent will be used.
2427 2427
2428 2428 The dirstate will be set to the files of the given revision.
2429 2429 The actual working directory content or existing dirstate
2430 2430 information such as adds or removes is not considered.
2431 2431
2432 2432 One use of this command is to make the next :hg:`status` invocation
2433 2433 check the actual file content.
2434 2434 """
2435 2435 ctx = scmutil.revsingle(repo, rev)
2436 2436 wlock = repo.wlock()
2437 2437 try:
2438 2438 repo.dirstate.rebuild(ctx.node(), ctx.manifest())
2439 2439 finally:
2440 2440 wlock.release()
2441 2441
2442 2442 @command('debugrename',
2443 2443 [('r', 'rev', '', _('revision to debug'), _('REV'))],
2444 2444 _('[-r REV] FILE'))
2445 2445 def debugrename(ui, repo, file1, *pats, **opts):
2446 2446 """dump rename information"""
2447 2447
2448 2448 ctx = scmutil.revsingle(repo, opts.get('rev'))
2449 2449 m = scmutil.match(ctx, (file1,) + pats, opts)
2450 2450 for abs in ctx.walk(m):
2451 2451 fctx = ctx[abs]
2452 2452 o = fctx.filelog().renamed(fctx.filenode())
2453 2453 rel = m.rel(abs)
2454 2454 if o:
2455 2455 ui.write(_("%s renamed from %s:%s\n") % (rel, o[0], hex(o[1])))
2456 2456 else:
2457 2457 ui.write(_("%s not renamed\n") % rel)
2458 2458
2459 2459 @command('debugrevlog',
2460 2460 [('c', 'changelog', False, _('open changelog')),
2461 2461 ('m', 'manifest', False, _('open manifest')),
2462 2462 ('d', 'dump', False, _('dump index data'))],
2463 2463 _('-c|-m|FILE'))
2464 2464 def debugrevlog(ui, repo, file_=None, **opts):
2465 2465 """show data and statistics about a revlog"""
2466 2466 r = cmdutil.openrevlog(repo, 'debugrevlog', file_, opts)
2467 2467
2468 2468 if opts.get("dump"):
2469 2469 numrevs = len(r)
2470 2470 ui.write("# rev p1rev p2rev start end deltastart base p1 p2"
2471 2471 " rawsize totalsize compression heads\n")
2472 2472 ts = 0
2473 2473 heads = set()
2474 2474 for rev in xrange(numrevs):
2475 2475 dbase = r.deltaparent(rev)
2476 2476 if dbase == -1:
2477 2477 dbase = rev
2478 2478 cbase = r.chainbase(rev)
2479 2479 p1, p2 = r.parentrevs(rev)
2480 2480 rs = r.rawsize(rev)
2481 2481 ts = ts + rs
2482 2482 heads -= set(r.parentrevs(rev))
2483 2483 heads.add(rev)
2484 2484 ui.write("%5d %5d %5d %5d %5d %10d %4d %4d %4d %7d %9d %11d %5d\n" %
2485 2485 (rev, p1, p2, r.start(rev), r.end(rev),
2486 2486 r.start(dbase), r.start(cbase),
2487 2487 r.start(p1), r.start(p2),
2488 2488 rs, ts, ts / r.end(rev), len(heads)))
2489 2489 return 0
2490 2490
2491 2491 v = r.version
2492 2492 format = v & 0xFFFF
2493 2493 flags = []
2494 2494 gdelta = False
2495 2495 if v & revlog.REVLOGNGINLINEDATA:
2496 2496 flags.append('inline')
2497 2497 if v & revlog.REVLOGGENERALDELTA:
2498 2498 gdelta = True
2499 2499 flags.append('generaldelta')
2500 2500 if not flags:
2501 2501 flags = ['(none)']
2502 2502
2503 2503 nummerges = 0
2504 2504 numfull = 0
2505 2505 numprev = 0
2506 2506 nump1 = 0
2507 2507 nump2 = 0
2508 2508 numother = 0
2509 2509 nump1prev = 0
2510 2510 nump2prev = 0
2511 2511 chainlengths = []
2512 2512
2513 2513 datasize = [None, 0, 0L]
2514 2514 fullsize = [None, 0, 0L]
2515 2515 deltasize = [None, 0, 0L]
2516 2516
2517 2517 def addsize(size, l):
2518 2518 if l[0] is None or size < l[0]:
2519 2519 l[0] = size
2520 2520 if size > l[1]:
2521 2521 l[1] = size
2522 2522 l[2] += size
2523 2523
2524 2524 numrevs = len(r)
2525 2525 for rev in xrange(numrevs):
2526 2526 p1, p2 = r.parentrevs(rev)
2527 2527 delta = r.deltaparent(rev)
2528 2528 if format > 0:
2529 2529 addsize(r.rawsize(rev), datasize)
2530 2530 if p2 != nullrev:
2531 2531 nummerges += 1
2532 2532 size = r.length(rev)
2533 2533 if delta == nullrev:
2534 2534 chainlengths.append(0)
2535 2535 numfull += 1
2536 2536 addsize(size, fullsize)
2537 2537 else:
2538 2538 chainlengths.append(chainlengths[delta] + 1)
2539 2539 addsize(size, deltasize)
2540 2540 if delta == rev - 1:
2541 2541 numprev += 1
2542 2542 if delta == p1:
2543 2543 nump1prev += 1
2544 2544 elif delta == p2:
2545 2545 nump2prev += 1
2546 2546 elif delta == p1:
2547 2547 nump1 += 1
2548 2548 elif delta == p2:
2549 2549 nump2 += 1
2550 2550 elif delta != nullrev:
2551 2551 numother += 1
2552 2552
2553 2553 # Adjust size min value for empty cases
2554 2554 for size in (datasize, fullsize, deltasize):
2555 2555 if size[0] is None:
2556 2556 size[0] = 0
2557 2557
2558 2558 numdeltas = numrevs - numfull
2559 2559 numoprev = numprev - nump1prev - nump2prev
2560 2560 totalrawsize = datasize[2]
2561 2561 datasize[2] /= numrevs
2562 2562 fulltotal = fullsize[2]
2563 2563 fullsize[2] /= numfull
2564 2564 deltatotal = deltasize[2]
2565 2565 if numrevs - numfull > 0:
2566 2566 deltasize[2] /= numrevs - numfull
2567 2567 totalsize = fulltotal + deltatotal
2568 2568 avgchainlen = sum(chainlengths) / numrevs
2569 2569 compratio = totalrawsize / totalsize
2570 2570
2571 2571 basedfmtstr = '%%%dd\n'
2572 2572 basepcfmtstr = '%%%dd %s(%%5.2f%%%%)\n'
2573 2573
2574 2574 def dfmtstr(max):
2575 2575 return basedfmtstr % len(str(max))
2576 2576 def pcfmtstr(max, padding=0):
2577 2577 return basepcfmtstr % (len(str(max)), ' ' * padding)
2578 2578
2579 2579 def pcfmt(value, total):
2580 2580 return (value, 100 * float(value) / total)
2581 2581
2582 2582 ui.write(('format : %d\n') % format)
2583 2583 ui.write(('flags : %s\n') % ', '.join(flags))
2584 2584
2585 2585 ui.write('\n')
2586 2586 fmt = pcfmtstr(totalsize)
2587 2587 fmt2 = dfmtstr(totalsize)
2588 2588 ui.write(('revisions : ') + fmt2 % numrevs)
2589 2589 ui.write((' merges : ') + fmt % pcfmt(nummerges, numrevs))
2590 2590 ui.write((' normal : ') + fmt % pcfmt(numrevs - nummerges, numrevs))
2591 2591 ui.write(('revisions : ') + fmt2 % numrevs)
2592 2592 ui.write((' full : ') + fmt % pcfmt(numfull, numrevs))
2593 2593 ui.write((' deltas : ') + fmt % pcfmt(numdeltas, numrevs))
2594 2594 ui.write(('revision size : ') + fmt2 % totalsize)
2595 2595 ui.write((' full : ') + fmt % pcfmt(fulltotal, totalsize))
2596 2596 ui.write((' deltas : ') + fmt % pcfmt(deltatotal, totalsize))
2597 2597
2598 2598 ui.write('\n')
2599 2599 fmt = dfmtstr(max(avgchainlen, compratio))
2600 2600 ui.write(('avg chain length : ') + fmt % avgchainlen)
2601 2601 ui.write(('compression ratio : ') + fmt % compratio)
2602 2602
2603 2603 if format > 0:
2604 2604 ui.write('\n')
2605 2605 ui.write(('uncompressed data size (min/max/avg) : %d / %d / %d\n')
2606 2606 % tuple(datasize))
2607 2607 ui.write(('full revision size (min/max/avg) : %d / %d / %d\n')
2608 2608 % tuple(fullsize))
2609 2609 ui.write(('delta size (min/max/avg) : %d / %d / %d\n')
2610 2610 % tuple(deltasize))
2611 2611
2612 2612 if numdeltas > 0:
2613 2613 ui.write('\n')
2614 2614 fmt = pcfmtstr(numdeltas)
2615 2615 fmt2 = pcfmtstr(numdeltas, 4)
2616 2616 ui.write(('deltas against prev : ') + fmt % pcfmt(numprev, numdeltas))
2617 2617 if numprev > 0:
2618 2618 ui.write((' where prev = p1 : ') + fmt2 % pcfmt(nump1prev,
2619 2619 numprev))
2620 2620 ui.write((' where prev = p2 : ') + fmt2 % pcfmt(nump2prev,
2621 2621 numprev))
2622 2622 ui.write((' other : ') + fmt2 % pcfmt(numoprev,
2623 2623 numprev))
2624 2624 if gdelta:
2625 2625 ui.write(('deltas against p1 : ')
2626 2626 + fmt % pcfmt(nump1, numdeltas))
2627 2627 ui.write(('deltas against p2 : ')
2628 2628 + fmt % pcfmt(nump2, numdeltas))
2629 2629 ui.write(('deltas against other : ') + fmt % pcfmt(numother,
2630 2630 numdeltas))
2631 2631
2632 2632 @command('debugrevspec',
2633 2633 [('', 'optimize', None, _('print parsed tree after optimizing'))],
2634 2634 ('REVSPEC'))
2635 2635 def debugrevspec(ui, repo, expr, **opts):
2636 2636 """parse and apply a revision specification
2637 2637
2638 2638 Use --verbose to print the parsed tree before and after aliases
2639 2639 expansion.
2640 2640 """
2641 2641 if ui.verbose:
2642 2642 tree = revset.parse(expr)[0]
2643 2643 ui.note(revset.prettyformat(tree), "\n")
2644 2644 newtree = revset.findaliases(ui, tree)
2645 2645 if newtree != tree:
2646 2646 ui.note(revset.prettyformat(newtree), "\n")
2647 2647 if opts["optimize"]:
2648 2648 weight, optimizedtree = revset.optimize(newtree, True)
2649 2649 ui.note("* optimized:\n", revset.prettyformat(optimizedtree), "\n")
2650 2650 func = revset.match(ui, expr)
2651 2651 for c in func(repo, revset.spanset(repo)):
2652 2652 ui.write("%s\n" % c)
2653 2653
2654 2654 @command('debugsetparents', [], _('REV1 [REV2]'))
2655 2655 def debugsetparents(ui, repo, rev1, rev2=None):
2656 2656 """manually set the parents of the current working directory
2657 2657
2658 2658 This is useful for writing repository conversion tools, but should
2659 2659 be used with care.
2660 2660
2661 2661 Returns 0 on success.
2662 2662 """
2663 2663
2664 2664 r1 = scmutil.revsingle(repo, rev1).node()
2665 2665 r2 = scmutil.revsingle(repo, rev2, 'null').node()
2666 2666
2667 2667 wlock = repo.wlock()
2668 2668 try:
2669 2669 repo.setparents(r1, r2)
2670 2670 finally:
2671 2671 wlock.release()
2672 2672
2673 2673 @command('debugdirstate|debugstate',
2674 2674 [('', 'nodates', None, _('do not display the saved mtime')),
2675 2675 ('', 'datesort', None, _('sort by saved mtime'))],
2676 2676 _('[OPTION]...'))
2677 2677 def debugstate(ui, repo, nodates=None, datesort=None):
2678 2678 """show the contents of the current dirstate"""
2679 2679 timestr = ""
2680 2680 showdate = not nodates
2681 2681 if datesort:
2682 2682 keyfunc = lambda x: (x[1][3], x[0]) # sort by mtime, then by filename
2683 2683 else:
2684 2684 keyfunc = None # sort by filename
2685 2685 for file_, ent in sorted(repo.dirstate._map.iteritems(), key=keyfunc):
2686 2686 if showdate:
2687 2687 if ent[3] == -1:
2688 2688 # Pad or slice to locale representation
2689 2689 locale_len = len(time.strftime("%Y-%m-%d %H:%M:%S ",
2690 2690 time.localtime(0)))
2691 2691 timestr = 'unset'
2692 2692 timestr = (timestr[:locale_len] +
2693 2693 ' ' * (locale_len - len(timestr)))
2694 2694 else:
2695 2695 timestr = time.strftime("%Y-%m-%d %H:%M:%S ",
2696 2696 time.localtime(ent[3]))
2697 2697 if ent[1] & 020000:
2698 2698 mode = 'lnk'
2699 2699 else:
2700 2700 mode = '%3o' % (ent[1] & 0777 & ~util.umask)
2701 2701 ui.write("%c %s %10d %s%s\n" % (ent[0], mode, ent[2], timestr, file_))
2702 2702 for f in repo.dirstate.copies():
2703 2703 ui.write(_("copy: %s -> %s\n") % (repo.dirstate.copied(f), f))
2704 2704
2705 2705 @command('debugsub',
2706 2706 [('r', 'rev', '',
2707 2707 _('revision to check'), _('REV'))],
2708 2708 _('[-r REV] [REV]'))
2709 2709 def debugsub(ui, repo, rev=None):
2710 2710 ctx = scmutil.revsingle(repo, rev, None)
2711 2711 for k, v in sorted(ctx.substate.items()):
2712 2712 ui.write(('path %s\n') % k)
2713 2713 ui.write((' source %s\n') % v[0])
2714 2714 ui.write((' revision %s\n') % v[1])
2715 2715
2716 2716 @command('debugsuccessorssets',
2717 2717 [],
2718 2718 _('[REV]'))
2719 2719 def debugsuccessorssets(ui, repo, *revs):
2720 2720 """show set of successors for revision
2721 2721
2722 2722 A successors set of changeset A is a consistent group of revisions that
2723 2723 succeed A. It contains non-obsolete changesets only.
2724 2724
2725 2725 In most cases a changeset A has a single successors set containing a single
2726 2726 successor (changeset A replaced by A').
2727 2727
2728 2728 A changeset that is made obsolete with no successors are called "pruned".
2729 2729 Such changesets have no successors sets at all.
2730 2730
2731 2731 A changeset that has been "split" will have a successors set containing
2732 2732 more than one successor.
2733 2733
2734 2734 A changeset that has been rewritten in multiple different ways is called
2735 2735 "divergent". Such changesets have multiple successor sets (each of which
2736 2736 may also be split, i.e. have multiple successors).
2737 2737
2738 2738 Results are displayed as follows::
2739 2739
2740 2740 <rev1>
2741 2741 <successors-1A>
2742 2742 <rev2>
2743 2743 <successors-2A>
2744 2744 <successors-2B1> <successors-2B2> <successors-2B3>
2745 2745
2746 2746 Here rev2 has two possible (i.e. divergent) successors sets. The first
2747 2747 holds one element, whereas the second holds three (i.e. the changeset has
2748 2748 been split).
2749 2749 """
2750 2750 # passed to successorssets caching computation from one call to another
2751 2751 cache = {}
2752 2752 ctx2str = str
2753 2753 node2str = short
2754 2754 if ui.debug():
2755 2755 def ctx2str(ctx):
2756 2756 return ctx.hex()
2757 2757 node2str = hex
2758 2758 for rev in scmutil.revrange(repo, revs):
2759 2759 ctx = repo[rev]
2760 2760 ui.write('%s\n'% ctx2str(ctx))
2761 2761 for succsset in obsolete.successorssets(repo, ctx.node(), cache):
2762 2762 if succsset:
2763 2763 ui.write(' ')
2764 2764 ui.write(node2str(succsset[0]))
2765 2765 for node in succsset[1:]:
2766 2766 ui.write(' ')
2767 2767 ui.write(node2str(node))
2768 2768 ui.write('\n')
2769 2769
2770 2770 @command('debugwalk', walkopts, _('[OPTION]... [FILE]...'))
2771 2771 def debugwalk(ui, repo, *pats, **opts):
2772 2772 """show how files match on given patterns"""
2773 2773 m = scmutil.match(repo[None], pats, opts)
2774 2774 items = list(repo.walk(m))
2775 2775 if not items:
2776 2776 return
2777 2777 f = lambda fn: fn
2778 2778 if ui.configbool('ui', 'slash') and os.sep != '/':
2779 2779 f = lambda fn: util.normpath(fn)
2780 2780 fmt = 'f %%-%ds %%-%ds %%s' % (
2781 2781 max([len(abs) for abs in items]),
2782 2782 max([len(m.rel(abs)) for abs in items]))
2783 2783 for abs in items:
2784 2784 line = fmt % (abs, f(m.rel(abs)), m.exact(abs) and 'exact' or '')
2785 2785 ui.write("%s\n" % line.rstrip())
2786 2786
2787 2787 @command('debugwireargs',
2788 2788 [('', 'three', '', 'three'),
2789 2789 ('', 'four', '', 'four'),
2790 2790 ('', 'five', '', 'five'),
2791 2791 ] + remoteopts,
2792 2792 _('REPO [OPTIONS]... [ONE [TWO]]'))
2793 2793 def debugwireargs(ui, repopath, *vals, **opts):
2794 2794 repo = hg.peer(ui, opts, repopath)
2795 2795 for opt in remoteopts:
2796 2796 del opts[opt[1]]
2797 2797 args = {}
2798 2798 for k, v in opts.iteritems():
2799 2799 if v:
2800 2800 args[k] = v
2801 2801 # run twice to check that we don't mess up the stream for the next command
2802 2802 res1 = repo.debugwireargs(*vals, **args)
2803 2803 res2 = repo.debugwireargs(*vals, **args)
2804 2804 ui.write("%s\n" % res1)
2805 2805 if res1 != res2:
2806 2806 ui.warn("%s\n" % res2)
2807 2807
2808 2808 @command('^diff',
2809 2809 [('r', 'rev', [], _('revision'), _('REV')),
2810 2810 ('c', 'change', '', _('change made by revision'), _('REV'))
2811 2811 ] + diffopts + diffopts2 + walkopts + subrepoopts,
2812 2812 _('[OPTION]... ([-c REV] | [-r REV1 [-r REV2]]) [FILE]...'))
2813 2813 def diff(ui, repo, *pats, **opts):
2814 2814 """diff repository (or selected files)
2815 2815
2816 2816 Show differences between revisions for the specified files.
2817 2817
2818 2818 Differences between files are shown using the unified diff format.
2819 2819
2820 2820 .. note::
2821 2821
2822 2822 diff may generate unexpected results for merges, as it will
2823 2823 default to comparing against the working directory's first
2824 2824 parent changeset if no revisions are specified.
2825 2825
2826 2826 When two revision arguments are given, then changes are shown
2827 2827 between those revisions. If only one revision is specified then
2828 2828 that revision is compared to the working directory, and, when no
2829 2829 revisions are specified, the working directory files are compared
2830 2830 to its parent.
2831 2831
2832 2832 Alternatively you can specify -c/--change with a revision to see
2833 2833 the changes in that changeset relative to its first parent.
2834 2834
2835 2835 Without the -a/--text option, diff will avoid generating diffs of
2836 2836 files it detects as binary. With -a, diff will generate a diff
2837 2837 anyway, probably with undesirable results.
2838 2838
2839 2839 Use the -g/--git option to generate diffs in the git extended diff
2840 2840 format. For more information, read :hg:`help diffs`.
2841 2841
2842 2842 .. container:: verbose
2843 2843
2844 2844 Examples:
2845 2845
2846 2846 - compare a file in the current working directory to its parent::
2847 2847
2848 2848 hg diff foo.c
2849 2849
2850 2850 - compare two historical versions of a directory, with rename info::
2851 2851
2852 2852 hg diff --git -r 1.0:1.2 lib/
2853 2853
2854 2854 - get change stats relative to the last change on some date::
2855 2855
2856 2856 hg diff --stat -r "date('may 2')"
2857 2857
2858 2858 - diff all newly-added files that contain a keyword::
2859 2859
2860 2860 hg diff "set:added() and grep(GNU)"
2861 2861
2862 2862 - compare a revision and its parents::
2863 2863
2864 2864 hg diff -c 9353 # compare against first parent
2865 2865 hg diff -r 9353^:9353 # same using revset syntax
2866 2866 hg diff -r 9353^2:9353 # compare against the second parent
2867 2867
2868 2868 Returns 0 on success.
2869 2869 """
2870 2870
2871 2871 revs = opts.get('rev')
2872 2872 change = opts.get('change')
2873 2873 stat = opts.get('stat')
2874 2874 reverse = opts.get('reverse')
2875 2875
2876 2876 if revs and change:
2877 2877 msg = _('cannot specify --rev and --change at the same time')
2878 2878 raise util.Abort(msg)
2879 2879 elif change:
2880 2880 node2 = scmutil.revsingle(repo, change, None).node()
2881 2881 node1 = repo[node2].p1().node()
2882 2882 else:
2883 2883 node1, node2 = scmutil.revpair(repo, revs)
2884 2884
2885 2885 if reverse:
2886 2886 node1, node2 = node2, node1
2887 2887
2888 2888 diffopts = patch.diffopts(ui, opts)
2889 2889 m = scmutil.match(repo[node2], pats, opts)
2890 2890 cmdutil.diffordiffstat(ui, repo, diffopts, node1, node2, m, stat=stat,
2891 2891 listsubrepos=opts.get('subrepos'))
2892 2892
2893 2893 @command('^export',
2894 2894 [('o', 'output', '',
2895 2895 _('print output to file with formatted name'), _('FORMAT')),
2896 2896 ('', 'switch-parent', None, _('diff against the second parent')),
2897 2897 ('r', 'rev', [], _('revisions to export'), _('REV')),
2898 2898 ] + diffopts,
2899 2899 _('[OPTION]... [-o OUTFILESPEC] [-r] [REV]...'))
2900 2900 def export(ui, repo, *changesets, **opts):
2901 2901 """dump the header and diffs for one or more changesets
2902 2902
2903 2903 Print the changeset header and diffs for one or more revisions.
2904 2904 If no revision is given, the parent of the working directory is used.
2905 2905
2906 2906 The information shown in the changeset header is: author, date,
2907 2907 branch name (if non-default), changeset hash, parent(s) and commit
2908 2908 comment.
2909 2909
2910 2910 .. note::
2911 2911
2912 2912 export may generate unexpected diff output for merge
2913 2913 changesets, as it will compare the merge changeset against its
2914 2914 first parent only.
2915 2915
2916 2916 Output may be to a file, in which case the name of the file is
2917 2917 given using a format string. The formatting rules are as follows:
2918 2918
2919 2919 :``%%``: literal "%" character
2920 2920 :``%H``: changeset hash (40 hexadecimal digits)
2921 2921 :``%N``: number of patches being generated
2922 2922 :``%R``: changeset revision number
2923 2923 :``%b``: basename of the exporting repository
2924 2924 :``%h``: short-form changeset hash (12 hexadecimal digits)
2925 2925 :``%m``: first line of the commit message (only alphanumeric characters)
2926 2926 :``%n``: zero-padded sequence number, starting at 1
2927 2927 :``%r``: zero-padded changeset revision number
2928 2928
2929 2929 Without the -a/--text option, export will avoid generating diffs
2930 2930 of files it detects as binary. With -a, export will generate a
2931 2931 diff anyway, probably with undesirable results.
2932 2932
2933 2933 Use the -g/--git option to generate diffs in the git extended diff
2934 2934 format. See :hg:`help diffs` for more information.
2935 2935
2936 2936 With the --switch-parent option, the diff will be against the
2937 2937 second parent. It can be useful to review a merge.
2938 2938
2939 2939 .. container:: verbose
2940 2940
2941 2941 Examples:
2942 2942
2943 2943 - use export and import to transplant a bugfix to the current
2944 2944 branch::
2945 2945
2946 2946 hg export -r 9353 | hg import -
2947 2947
2948 2948 - export all the changesets between two revisions to a file with
2949 2949 rename information::
2950 2950
2951 2951 hg export --git -r 123:150 > changes.txt
2952 2952
2953 2953 - split outgoing changes into a series of patches with
2954 2954 descriptive names::
2955 2955
2956 2956 hg export -r "outgoing()" -o "%n-%m.patch"
2957 2957
2958 2958 Returns 0 on success.
2959 2959 """
2960 2960 changesets += tuple(opts.get('rev', []))
2961 2961 if not changesets:
2962 2962 changesets = ['.']
2963 2963 revs = scmutil.revrange(repo, changesets)
2964 2964 if not revs:
2965 2965 raise util.Abort(_("export requires at least one changeset"))
2966 2966 if len(revs) > 1:
2967 2967 ui.note(_('exporting patches:\n'))
2968 2968 else:
2969 2969 ui.note(_('exporting patch:\n'))
2970 2970 cmdutil.export(repo, revs, template=opts.get('output'),
2971 2971 switch_parent=opts.get('switch_parent'),
2972 2972 opts=patch.diffopts(ui, opts))
2973 2973
2974 2974 @command('^forget', walkopts, _('[OPTION]... FILE...'))
2975 2975 def forget(ui, repo, *pats, **opts):
2976 2976 """forget the specified files on the next commit
2977 2977
2978 2978 Mark the specified files so they will no longer be tracked
2979 2979 after the next commit.
2980 2980
2981 2981 This only removes files from the current branch, not from the
2982 2982 entire project history, and it does not delete them from the
2983 2983 working directory.
2984 2984
2985 2985 To undo a forget before the next commit, see :hg:`add`.
2986 2986
2987 2987 .. container:: verbose
2988 2988
2989 2989 Examples:
2990 2990
2991 2991 - forget newly-added binary files::
2992 2992
2993 2993 hg forget "set:added() and binary()"
2994 2994
2995 2995 - forget files that would be excluded by .hgignore::
2996 2996
2997 2997 hg forget "set:hgignore()"
2998 2998
2999 2999 Returns 0 on success.
3000 3000 """
3001 3001
3002 3002 if not pats:
3003 3003 raise util.Abort(_('no files specified'))
3004 3004
3005 3005 m = scmutil.match(repo[None], pats, opts)
3006 3006 rejected = cmdutil.forget(ui, repo, m, prefix="", explicitonly=False)[0]
3007 3007 return rejected and 1 or 0
3008 3008
3009 3009 @command(
3010 3010 'graft',
3011 3011 [('r', 'rev', [], _('revisions to graft'), _('REV')),
3012 3012 ('c', 'continue', False, _('resume interrupted graft')),
3013 3013 ('e', 'edit', False, _('invoke editor on commit messages')),
3014 3014 ('', 'log', None, _('append graft info to log message')),
3015 3015 ('D', 'currentdate', False,
3016 3016 _('record the current date as commit date')),
3017 3017 ('U', 'currentuser', False,
3018 3018 _('record the current user as committer'), _('DATE'))]
3019 3019 + commitopts2 + mergetoolopts + dryrunopts,
3020 3020 _('[OPTION]... [-r] REV...'))
3021 3021 def graft(ui, repo, *revs, **opts):
3022 3022 '''copy changes from other branches onto the current branch
3023 3023
3024 3024 This command uses Mercurial's merge logic to copy individual
3025 3025 changes from other branches without merging branches in the
3026 3026 history graph. This is sometimes known as 'backporting' or
3027 3027 'cherry-picking'. By default, graft will copy user, date, and
3028 3028 description from the source changesets.
3029 3029
3030 3030 Changesets that are ancestors of the current revision, that have
3031 3031 already been grafted, or that are merges will be skipped.
3032 3032
3033 3033 If --log is specified, log messages will have a comment appended
3034 3034 of the form::
3035 3035
3036 3036 (grafted from CHANGESETHASH)
3037 3037
3038 3038 If a graft merge results in conflicts, the graft process is
3039 3039 interrupted so that the current merge can be manually resolved.
3040 3040 Once all conflicts are addressed, the graft process can be
3041 3041 continued with the -c/--continue option.
3042 3042
3043 3043 .. note::
3044 3044
3045 3045 The -c/--continue option does not reapply earlier options.
3046 3046
3047 3047 .. container:: verbose
3048 3048
3049 3049 Examples:
3050 3050
3051 3051 - copy a single change to the stable branch and edit its description::
3052 3052
3053 3053 hg update stable
3054 3054 hg graft --edit 9393
3055 3055
3056 3056 - graft a range of changesets with one exception, updating dates::
3057 3057
3058 3058 hg graft -D "2085::2093 and not 2091"
3059 3059
3060 3060 - continue a graft after resolving conflicts::
3061 3061
3062 3062 hg graft -c
3063 3063
3064 3064 - show the source of a grafted changeset::
3065 3065
3066 3066 hg log --debug -r .
3067 3067
3068 3068 Returns 0 on successful completion.
3069 3069 '''
3070 3070
3071 3071 revs = list(revs)
3072 3072 revs.extend(opts['rev'])
3073 3073
3074 3074 if not opts.get('user') and opts.get('currentuser'):
3075 3075 opts['user'] = ui.username()
3076 3076 if not opts.get('date') and opts.get('currentdate'):
3077 3077 opts['date'] = "%d %d" % util.makedate()
3078 3078
3079 3079 editor = None
3080 3080 if opts.get('edit'):
3081 3081 editor = cmdutil.commitforceeditor
3082 3082
3083 3083 cont = False
3084 3084 if opts['continue']:
3085 3085 cont = True
3086 3086 if revs:
3087 3087 raise util.Abort(_("can't specify --continue and revisions"))
3088 3088 # read in unfinished revisions
3089 3089 try:
3090 3090 nodes = repo.opener.read('graftstate').splitlines()
3091 3091 revs = [repo[node].rev() for node in nodes]
3092 3092 except IOError, inst:
3093 3093 if inst.errno != errno.ENOENT:
3094 3094 raise
3095 3095 raise util.Abort(_("no graft state found, can't continue"))
3096 3096 else:
3097 3097 cmdutil.checkunfinished(repo)
3098 3098 cmdutil.bailifchanged(repo)
3099 3099 if not revs:
3100 3100 raise util.Abort(_('no revisions specified'))
3101 3101 revs = scmutil.revrange(repo, revs)
3102 3102
3103 3103 # check for merges
3104 3104 for rev in repo.revs('%ld and merge()', revs):
3105 3105 ui.warn(_('skipping ungraftable merge revision %s\n') % rev)
3106 3106 revs.remove(rev)
3107 3107 if not revs:
3108 3108 return -1
3109 3109
3110 3110 # check for ancestors of dest branch
3111 3111 crev = repo['.'].rev()
3112 3112 ancestors = repo.changelog.ancestors([crev], inclusive=True)
3113 3113 # Cannot use x.remove(y) on smart set, this has to be a list.
3114 3114 # XXX make this lazy in the future
3115 3115 revs = list(revs)
3116 3116 # don't mutate while iterating, create a copy
3117 3117 for rev in list(revs):
3118 3118 if rev in ancestors:
3119 3119 ui.warn(_('skipping ancestor revision %s\n') % rev)
3120 3120 # XXX remove on list is slow
3121 3121 revs.remove(rev)
3122 3122 if not revs:
3123 3123 return -1
3124 3124
3125 3125 # analyze revs for earlier grafts
3126 3126 ids = {}
3127 3127 for ctx in repo.set("%ld", revs):
3128 3128 ids[ctx.hex()] = ctx.rev()
3129 3129 n = ctx.extra().get('source')
3130 3130 if n:
3131 3131 ids[n] = ctx.rev()
3132 3132
3133 3133 # check ancestors for earlier grafts
3134 3134 ui.debug('scanning for duplicate grafts\n')
3135 3135
3136 3136 for rev in repo.changelog.findmissingrevs(revs, [crev]):
3137 3137 ctx = repo[rev]
3138 3138 n = ctx.extra().get('source')
3139 3139 if n in ids:
3140 3140 r = repo[n].rev()
3141 3141 if r in revs:
3142 3142 ui.warn(_('skipping revision %s (already grafted to %s)\n')
3143 3143 % (r, rev))
3144 3144 revs.remove(r)
3145 3145 elif ids[n] in revs:
3146 3146 ui.warn(_('skipping already grafted revision %s '
3147 3147 '(%s also has origin %d)\n') % (ids[n], rev, r))
3148 3148 revs.remove(ids[n])
3149 3149 elif ctx.hex() in ids:
3150 3150 r = ids[ctx.hex()]
3151 3151 ui.warn(_('skipping already grafted revision %s '
3152 3152 '(was grafted from %d)\n') % (r, rev))
3153 3153 revs.remove(r)
3154 3154 if not revs:
3155 3155 return -1
3156 3156
3157 3157 wlock = repo.wlock()
3158 3158 try:
3159 3159 current = repo['.']
3160 3160 for pos, ctx in enumerate(repo.set("%ld", revs)):
3161 3161
3162 3162 ui.status(_('grafting revision %s\n') % ctx.rev())
3163 3163 if opts.get('dry_run'):
3164 3164 continue
3165 3165
3166 3166 source = ctx.extra().get('source')
3167 3167 if not source:
3168 3168 source = ctx.hex()
3169 3169 extra = {'source': source}
3170 3170 user = ctx.user()
3171 3171 if opts.get('user'):
3172 3172 user = opts['user']
3173 3173 date = ctx.date()
3174 3174 if opts.get('date'):
3175 3175 date = opts['date']
3176 3176 message = ctx.description()
3177 3177 if opts.get('log'):
3178 3178 message += '\n(grafted from %s)' % ctx.hex()
3179 3179
3180 3180 # we don't merge the first commit when continuing
3181 3181 if not cont:
3182 3182 # perform the graft merge with p1(rev) as 'ancestor'
3183 3183 try:
3184 3184 # ui.forcemerge is an internal variable, do not document
3185 3185 repo.ui.setconfig('ui', 'forcemerge', opts.get('tool', ''),
3186 3186 'graft')
3187 3187 stats = mergemod.update(repo, ctx.node(), True, True, False,
3188 3188 ctx.p1().node())
3189 3189 finally:
3190 3190 repo.ui.setconfig('ui', 'forcemerge', '', 'graft')
3191 3191 # report any conflicts
3192 3192 if stats and stats[3] > 0:
3193 3193 # write out state for --continue
3194 3194 nodelines = [repo[rev].hex() + "\n" for rev in revs[pos:]]
3195 3195 repo.opener.write('graftstate', ''.join(nodelines))
3196 3196 raise util.Abort(
3197 3197 _("unresolved conflicts, can't continue"),
3198 3198 hint=_('use hg resolve and hg graft --continue'))
3199 3199 else:
3200 3200 cont = False
3201 3201
3202 3202 # drop the second merge parent
3203 3203 repo.setparents(current.node(), nullid)
3204 3204 repo.dirstate.write()
3205 3205 # fix up dirstate for copies and renames
3206 3206 cmdutil.duplicatecopies(repo, ctx.rev(), ctx.p1().rev())
3207 3207
3208 3208 # commit
3209 3209 node = repo.commit(text=message, user=user,
3210 3210 date=date, extra=extra, editor=editor)
3211 3211 if node is None:
3212 3212 ui.status(_('graft for revision %s is empty\n') % ctx.rev())
3213 3213 else:
3214 3214 current = repo[node]
3215 3215 finally:
3216 3216 wlock.release()
3217 3217
3218 3218 # remove state when we complete successfully
3219 3219 if not opts.get('dry_run'):
3220 3220 util.unlinkpath(repo.join('graftstate'), ignoremissing=True)
3221 3221
3222 3222 return 0
3223 3223
3224 3224 @command('grep',
3225 3225 [('0', 'print0', None, _('end fields with NUL')),
3226 3226 ('', 'all', None, _('print all revisions that match')),
3227 3227 ('a', 'text', None, _('treat all files as text')),
3228 3228 ('f', 'follow', None,
3229 3229 _('follow changeset history,'
3230 3230 ' or file history across copies and renames')),
3231 3231 ('i', 'ignore-case', None, _('ignore case when matching')),
3232 3232 ('l', 'files-with-matches', None,
3233 3233 _('print only filenames and revisions that match')),
3234 3234 ('n', 'line-number', None, _('print matching line numbers')),
3235 3235 ('r', 'rev', [],
3236 3236 _('only search files changed within revision range'), _('REV')),
3237 3237 ('u', 'user', None, _('list the author (long with -v)')),
3238 3238 ('d', 'date', None, _('list the date (short with -q)')),
3239 3239 ] + walkopts,
3240 3240 _('[OPTION]... PATTERN [FILE]...'))
3241 3241 def grep(ui, repo, pattern, *pats, **opts):
3242 3242 """search for a pattern in specified files and revisions
3243 3243
3244 3244 Search revisions of files for a regular expression.
3245 3245
3246 3246 This command behaves differently than Unix grep. It only accepts
3247 3247 Python/Perl regexps. It searches repository history, not the
3248 3248 working directory. It always prints the revision number in which a
3249 3249 match appears.
3250 3250
3251 3251 By default, grep only prints output for the first revision of a
3252 3252 file in which it finds a match. To get it to print every revision
3253 3253 that contains a change in match status ("-" for a match that
3254 3254 becomes a non-match, or "+" for a non-match that becomes a match),
3255 3255 use the --all flag.
3256 3256
3257 3257 Returns 0 if a match is found, 1 otherwise.
3258 3258 """
3259 3259 reflags = re.M
3260 3260 if opts.get('ignore_case'):
3261 3261 reflags |= re.I
3262 3262 try:
3263 3263 regexp = util.compilere(pattern, reflags)
3264 3264 except re.error, inst:
3265 3265 ui.warn(_("grep: invalid match pattern: %s\n") % inst)
3266 3266 return 1
3267 3267 sep, eol = ':', '\n'
3268 3268 if opts.get('print0'):
3269 3269 sep = eol = '\0'
3270 3270
3271 3271 getfile = util.lrucachefunc(repo.file)
3272 3272
3273 3273 def matchlines(body):
3274 3274 begin = 0
3275 3275 linenum = 0
3276 3276 while begin < len(body):
3277 3277 match = regexp.search(body, begin)
3278 3278 if not match:
3279 3279 break
3280 3280 mstart, mend = match.span()
3281 3281 linenum += body.count('\n', begin, mstart) + 1
3282 3282 lstart = body.rfind('\n', begin, mstart) + 1 or begin
3283 3283 begin = body.find('\n', mend) + 1 or len(body) + 1
3284 3284 lend = begin - 1
3285 3285 yield linenum, mstart - lstart, mend - lstart, body[lstart:lend]
3286 3286
3287 3287 class linestate(object):
3288 3288 def __init__(self, line, linenum, colstart, colend):
3289 3289 self.line = line
3290 3290 self.linenum = linenum
3291 3291 self.colstart = colstart
3292 3292 self.colend = colend
3293 3293
3294 3294 def __hash__(self):
3295 3295 return hash((self.linenum, self.line))
3296 3296
3297 3297 def __eq__(self, other):
3298 3298 return self.line == other.line
3299 3299
3300 3300 def __iter__(self):
3301 3301 yield (self.line[:self.colstart], '')
3302 3302 yield (self.line[self.colstart:self.colend], 'grep.match')
3303 3303 rest = self.line[self.colend:]
3304 3304 while rest != '':
3305 3305 match = regexp.search(rest)
3306 3306 if not match:
3307 3307 yield (rest, '')
3308 3308 break
3309 3309 mstart, mend = match.span()
3310 3310 yield (rest[:mstart], '')
3311 3311 yield (rest[mstart:mend], 'grep.match')
3312 3312 rest = rest[mend:]
3313 3313
3314 3314 matches = {}
3315 3315 copies = {}
3316 3316 def grepbody(fn, rev, body):
3317 3317 matches[rev].setdefault(fn, [])
3318 3318 m = matches[rev][fn]
3319 3319 for lnum, cstart, cend, line in matchlines(body):
3320 3320 s = linestate(line, lnum, cstart, cend)
3321 3321 m.append(s)
3322 3322
3323 3323 def difflinestates(a, b):
3324 3324 sm = difflib.SequenceMatcher(None, a, b)
3325 3325 for tag, alo, ahi, blo, bhi in sm.get_opcodes():
3326 3326 if tag == 'insert':
3327 3327 for i in xrange(blo, bhi):
3328 3328 yield ('+', b[i])
3329 3329 elif tag == 'delete':
3330 3330 for i in xrange(alo, ahi):
3331 3331 yield ('-', a[i])
3332 3332 elif tag == 'replace':
3333 3333 for i in xrange(alo, ahi):
3334 3334 yield ('-', a[i])
3335 3335 for i in xrange(blo, bhi):
3336 3336 yield ('+', b[i])
3337 3337
3338 3338 def display(fn, ctx, pstates, states):
3339 3339 rev = ctx.rev()
3340 3340 datefunc = ui.quiet and util.shortdate or util.datestr
3341 3341 found = False
3342 3342 @util.cachefunc
3343 3343 def binary():
3344 3344 flog = getfile(fn)
3345 3345 return util.binary(flog.read(ctx.filenode(fn)))
3346 3346
3347 3347 if opts.get('all'):
3348 3348 iter = difflinestates(pstates, states)
3349 3349 else:
3350 3350 iter = [('', l) for l in states]
3351 3351 for change, l in iter:
3352 3352 cols = [(fn, 'grep.filename'), (str(rev), 'grep.rev')]
3353 3353
3354 3354 if opts.get('line_number'):
3355 3355 cols.append((str(l.linenum), 'grep.linenumber'))
3356 3356 if opts.get('all'):
3357 3357 cols.append((change, 'grep.change'))
3358 3358 if opts.get('user'):
3359 3359 cols.append((ui.shortuser(ctx.user()), 'grep.user'))
3360 3360 if opts.get('date'):
3361 3361 cols.append((datefunc(ctx.date()), 'grep.date'))
3362 3362 for col, label in cols[:-1]:
3363 3363 ui.write(col, label=label)
3364 3364 ui.write(sep, label='grep.sep')
3365 3365 ui.write(cols[-1][0], label=cols[-1][1])
3366 3366 if not opts.get('files_with_matches'):
3367 3367 ui.write(sep, label='grep.sep')
3368 3368 if not opts.get('text') and binary():
3369 3369 ui.write(" Binary file matches")
3370 3370 else:
3371 3371 for s, label in l:
3372 3372 ui.write(s, label=label)
3373 3373 ui.write(eol)
3374 3374 found = True
3375 3375 if opts.get('files_with_matches'):
3376 3376 break
3377 3377 return found
3378 3378
3379 3379 skip = {}
3380 3380 revfiles = {}
3381 3381 matchfn = scmutil.match(repo[None], pats, opts)
3382 3382 found = False
3383 3383 follow = opts.get('follow')
3384 3384
3385 3385 def prep(ctx, fns):
3386 3386 rev = ctx.rev()
3387 3387 pctx = ctx.p1()
3388 3388 parent = pctx.rev()
3389 3389 matches.setdefault(rev, {})
3390 3390 matches.setdefault(parent, {})
3391 3391 files = revfiles.setdefault(rev, [])
3392 3392 for fn in fns:
3393 3393 flog = getfile(fn)
3394 3394 try:
3395 3395 fnode = ctx.filenode(fn)
3396 3396 except error.LookupError:
3397 3397 continue
3398 3398
3399 3399 copied = flog.renamed(fnode)
3400 3400 copy = follow and copied and copied[0]
3401 3401 if copy:
3402 3402 copies.setdefault(rev, {})[fn] = copy
3403 3403 if fn in skip:
3404 3404 if copy:
3405 3405 skip[copy] = True
3406 3406 continue
3407 3407 files.append(fn)
3408 3408
3409 3409 if fn not in matches[rev]:
3410 3410 grepbody(fn, rev, flog.read(fnode))
3411 3411
3412 3412 pfn = copy or fn
3413 3413 if pfn not in matches[parent]:
3414 3414 try:
3415 3415 fnode = pctx.filenode(pfn)
3416 3416 grepbody(pfn, parent, flog.read(fnode))
3417 3417 except error.LookupError:
3418 3418 pass
3419 3419
3420 3420 for ctx in cmdutil.walkchangerevs(repo, matchfn, opts, prep):
3421 3421 rev = ctx.rev()
3422 3422 parent = ctx.p1().rev()
3423 3423 for fn in sorted(revfiles.get(rev, [])):
3424 3424 states = matches[rev][fn]
3425 3425 copy = copies.get(rev, {}).get(fn)
3426 3426 if fn in skip:
3427 3427 if copy:
3428 3428 skip[copy] = True
3429 3429 continue
3430 3430 pstates = matches.get(parent, {}).get(copy or fn, [])
3431 3431 if pstates or states:
3432 3432 r = display(fn, ctx, pstates, states)
3433 3433 found = found or r
3434 3434 if r and not opts.get('all'):
3435 3435 skip[fn] = True
3436 3436 if copy:
3437 3437 skip[copy] = True
3438 3438 del matches[rev]
3439 3439 del revfiles[rev]
3440 3440
3441 3441 return not found
3442 3442
3443 3443 @command('heads',
3444 3444 [('r', 'rev', '',
3445 3445 _('show only heads which are descendants of STARTREV'), _('STARTREV')),
3446 3446 ('t', 'topo', False, _('show topological heads only')),
3447 3447 ('a', 'active', False, _('show active branchheads only (DEPRECATED)')),
3448 3448 ('c', 'closed', False, _('show normal and closed branch heads')),
3449 3449 ] + templateopts,
3450 3450 _('[-ct] [-r STARTREV] [REV]...'))
3451 3451 def heads(ui, repo, *branchrevs, **opts):
3452 3452 """show branch heads
3453 3453
3454 3454 With no arguments, show all open branch heads in the repository.
3455 3455 Branch heads are changesets that have no descendants on the
3456 3456 same branch. They are where development generally takes place and
3457 3457 are the usual targets for update and merge operations.
3458 3458
3459 3459 If one or more REVs are given, only open branch heads on the
3460 3460 branches associated with the specified changesets are shown. This
3461 3461 means that you can use :hg:`heads .` to see the heads on the
3462 3462 currently checked-out branch.
3463 3463
3464 3464 If -c/--closed is specified, also show branch heads marked closed
3465 3465 (see :hg:`commit --close-branch`).
3466 3466
3467 3467 If STARTREV is specified, only those heads that are descendants of
3468 3468 STARTREV will be displayed.
3469 3469
3470 3470 If -t/--topo is specified, named branch mechanics will be ignored and only
3471 3471 topological heads (changesets with no children) will be shown.
3472 3472
3473 3473 Returns 0 if matching heads are found, 1 if not.
3474 3474 """
3475 3475
3476 3476 start = None
3477 3477 if 'rev' in opts:
3478 3478 start = scmutil.revsingle(repo, opts['rev'], None).node()
3479 3479
3480 3480 if opts.get('topo'):
3481 3481 heads = [repo[h] for h in repo.heads(start)]
3482 3482 else:
3483 3483 heads = []
3484 3484 for branch in repo.branchmap():
3485 3485 heads += repo.branchheads(branch, start, opts.get('closed'))
3486 3486 heads = [repo[h] for h in heads]
3487 3487
3488 3488 if branchrevs:
3489 3489 branches = set(repo[br].branch() for br in branchrevs)
3490 3490 heads = [h for h in heads if h.branch() in branches]
3491 3491
3492 3492 if opts.get('active') and branchrevs:
3493 3493 dagheads = repo.heads(start)
3494 3494 heads = [h for h in heads if h.node() in dagheads]
3495 3495
3496 3496 if branchrevs:
3497 3497 haveheads = set(h.branch() for h in heads)
3498 3498 if branches - haveheads:
3499 3499 headless = ', '.join(b for b in branches - haveheads)
3500 3500 msg = _('no open branch heads found on branches %s')
3501 3501 if opts.get('rev'):
3502 3502 msg += _(' (started at %s)') % opts['rev']
3503 3503 ui.warn((msg + '\n') % headless)
3504 3504
3505 3505 if not heads:
3506 3506 return 1
3507 3507
3508 3508 heads = sorted(heads, key=lambda x: -x.rev())
3509 3509 displayer = cmdutil.show_changeset(ui, repo, opts)
3510 3510 for ctx in heads:
3511 3511 displayer.show(ctx)
3512 3512 displayer.close()
3513 3513
3514 3514 @command('help',
3515 3515 [('e', 'extension', None, _('show only help for extensions')),
3516 3516 ('c', 'command', None, _('show only help for commands')),
3517 3517 ('k', 'keyword', '', _('show topics matching keyword')),
3518 3518 ],
3519 3519 _('[-ec] [TOPIC]'))
3520 3520 def help_(ui, name=None, **opts):
3521 3521 """show help for a given topic or a help overview
3522 3522
3523 3523 With no arguments, print a list of commands with short help messages.
3524 3524
3525 3525 Given a topic, extension, or command name, print help for that
3526 3526 topic.
3527 3527
3528 3528 Returns 0 if successful.
3529 3529 """
3530 3530
3531 3531 textwidth = min(ui.termwidth(), 80) - 2
3532 3532
3533 3533 keep = ui.verbose and ['verbose'] or []
3534 3534 text = help.help_(ui, name, **opts)
3535 3535
3536 3536 formatted, pruned = minirst.format(text, textwidth, keep=keep)
3537 3537 if 'verbose' in pruned:
3538 3538 keep.append('omitted')
3539 3539 else:
3540 3540 keep.append('notomitted')
3541 3541 formatted, pruned = minirst.format(text, textwidth, keep=keep)
3542 3542 ui.write(formatted)
3543 3543
3544 3544
3545 3545 @command('identify|id',
3546 3546 [('r', 'rev', '',
3547 3547 _('identify the specified revision'), _('REV')),
3548 3548 ('n', 'num', None, _('show local revision number')),
3549 3549 ('i', 'id', None, _('show global revision id')),
3550 3550 ('b', 'branch', None, _('show branch')),
3551 3551 ('t', 'tags', None, _('show tags')),
3552 3552 ('B', 'bookmarks', None, _('show bookmarks')),
3553 3553 ] + remoteopts,
3554 3554 _('[-nibtB] [-r REV] [SOURCE]'))
3555 3555 def identify(ui, repo, source=None, rev=None,
3556 3556 num=None, id=None, branch=None, tags=None, bookmarks=None, **opts):
3557 3557 """identify the working copy or specified revision
3558 3558
3559 3559 Print a summary identifying the repository state at REV using one or
3560 3560 two parent hash identifiers, followed by a "+" if the working
3561 3561 directory has uncommitted changes, the branch name (if not default),
3562 3562 a list of tags, and a list of bookmarks.
3563 3563
3564 3564 When REV is not given, print a summary of the current state of the
3565 3565 repository.
3566 3566
3567 3567 Specifying a path to a repository root or Mercurial bundle will
3568 3568 cause lookup to operate on that repository/bundle.
3569 3569
3570 3570 .. container:: verbose
3571 3571
3572 3572 Examples:
3573 3573
3574 3574 - generate a build identifier for the working directory::
3575 3575
3576 3576 hg id --id > build-id.dat
3577 3577
3578 3578 - find the revision corresponding to a tag::
3579 3579
3580 3580 hg id -n -r 1.3
3581 3581
3582 3582 - check the most recent revision of a remote repository::
3583 3583
3584 3584 hg id -r tip http://selenic.com/hg/
3585 3585
3586 3586 Returns 0 if successful.
3587 3587 """
3588 3588
3589 3589 if not repo and not source:
3590 3590 raise util.Abort(_("there is no Mercurial repository here "
3591 3591 "(.hg not found)"))
3592 3592
3593 3593 hexfunc = ui.debugflag and hex or short
3594 3594 default = not (num or id or branch or tags or bookmarks)
3595 3595 output = []
3596 3596 revs = []
3597 3597
3598 3598 if source:
3599 3599 source, branches = hg.parseurl(ui.expandpath(source))
3600 3600 peer = hg.peer(repo or ui, opts, source) # only pass ui when no repo
3601 3601 repo = peer.local()
3602 3602 revs, checkout = hg.addbranchrevs(repo, peer, branches, None)
3603 3603
3604 3604 if not repo:
3605 3605 if num or branch or tags:
3606 3606 raise util.Abort(
3607 3607 _("can't query remote revision number, branch, or tags"))
3608 3608 if not rev and revs:
3609 3609 rev = revs[0]
3610 3610 if not rev:
3611 3611 rev = "tip"
3612 3612
3613 3613 remoterev = peer.lookup(rev)
3614 3614 if default or id:
3615 3615 output = [hexfunc(remoterev)]
3616 3616
3617 3617 def getbms():
3618 3618 bms = []
3619 3619
3620 3620 if 'bookmarks' in peer.listkeys('namespaces'):
3621 3621 hexremoterev = hex(remoterev)
3622 3622 bms = [bm for bm, bmr in peer.listkeys('bookmarks').iteritems()
3623 3623 if bmr == hexremoterev]
3624 3624
3625 3625 return sorted(bms)
3626 3626
3627 3627 if bookmarks:
3628 3628 output.extend(getbms())
3629 3629 elif default and not ui.quiet:
3630 3630 # multiple bookmarks for a single parent separated by '/'
3631 3631 bm = '/'.join(getbms())
3632 3632 if bm:
3633 3633 output.append(bm)
3634 3634 else:
3635 3635 if not rev:
3636 3636 ctx = repo[None]
3637 3637 parents = ctx.parents()
3638 3638 changed = ""
3639 3639 if default or id or num:
3640 3640 if (util.any(repo.status())
3641 3641 or util.any(ctx.sub(s).dirty() for s in ctx.substate)):
3642 3642 changed = '+'
3643 3643 if default or id:
3644 3644 output = ["%s%s" %
3645 3645 ('+'.join([hexfunc(p.node()) for p in parents]), changed)]
3646 3646 if num:
3647 3647 output.append("%s%s" %
3648 3648 ('+'.join([str(p.rev()) for p in parents]), changed))
3649 3649 else:
3650 3650 ctx = scmutil.revsingle(repo, rev)
3651 3651 if default or id:
3652 3652 output = [hexfunc(ctx.node())]
3653 3653 if num:
3654 3654 output.append(str(ctx.rev()))
3655 3655
3656 3656 if default and not ui.quiet:
3657 3657 b = ctx.branch()
3658 3658 if b != 'default':
3659 3659 output.append("(%s)" % b)
3660 3660
3661 3661 # multiple tags for a single parent separated by '/'
3662 3662 t = '/'.join(ctx.tags())
3663 3663 if t:
3664 3664 output.append(t)
3665 3665
3666 3666 # multiple bookmarks for a single parent separated by '/'
3667 3667 bm = '/'.join(ctx.bookmarks())
3668 3668 if bm:
3669 3669 output.append(bm)
3670 3670 else:
3671 3671 if branch:
3672 3672 output.append(ctx.branch())
3673 3673
3674 3674 if tags:
3675 3675 output.extend(ctx.tags())
3676 3676
3677 3677 if bookmarks:
3678 3678 output.extend(ctx.bookmarks())
3679 3679
3680 3680 ui.write("%s\n" % ' '.join(output))
3681 3681
3682 3682 @command('import|patch',
3683 3683 [('p', 'strip', 1,
3684 3684 _('directory strip option for patch. This has the same '
3685 3685 'meaning as the corresponding patch option'), _('NUM')),
3686 3686 ('b', 'base', '', _('base path (DEPRECATED)'), _('PATH')),
3687 3687 ('e', 'edit', False, _('invoke editor on commit messages')),
3688 3688 ('f', 'force', None,
3689 3689 _('skip check for outstanding uncommitted changes (DEPRECATED)')),
3690 3690 ('', 'no-commit', None,
3691 3691 _("don't commit, just update the working directory")),
3692 3692 ('', 'bypass', None,
3693 3693 _("apply patch without touching the working directory")),
3694 3694 ('', 'exact', None,
3695 3695 _('apply patch to the nodes from which it was generated')),
3696 3696 ('', 'import-branch', None,
3697 3697 _('use any branch information in patch (implied by --exact)'))] +
3698 3698 commitopts + commitopts2 + similarityopts,
3699 3699 _('[OPTION]... PATCH...'))
3700 3700 def import_(ui, repo, patch1=None, *patches, **opts):
3701 3701 """import an ordered set of patches
3702 3702
3703 3703 Import a list of patches and commit them individually (unless
3704 3704 --no-commit is specified).
3705 3705
3706 3706 Because import first applies changes to the working directory,
3707 3707 import will abort if there are outstanding changes.
3708 3708
3709 3709 You can import a patch straight from a mail message. Even patches
3710 3710 as attachments work (to use the body part, it must have type
3711 3711 text/plain or text/x-patch). From and Subject headers of email
3712 3712 message are used as default committer and commit message. All
3713 3713 text/plain body parts before first diff are added to commit
3714 3714 message.
3715 3715
3716 3716 If the imported patch was generated by :hg:`export`, user and
3717 3717 description from patch override values from message headers and
3718 3718 body. Values given on command line with -m/--message and -u/--user
3719 3719 override these.
3720 3720
3721 3721 If --exact is specified, import will set the working directory to
3722 3722 the parent of each patch before applying it, and will abort if the
3723 3723 resulting changeset has a different ID than the one recorded in
3724 3724 the patch. This may happen due to character set problems or other
3725 3725 deficiencies in the text patch format.
3726 3726
3727 3727 Use --bypass to apply and commit patches directly to the
3728 3728 repository, not touching the working directory. Without --exact,
3729 3729 patches will be applied on top of the working directory parent
3730 3730 revision.
3731 3731
3732 3732 With -s/--similarity, hg will attempt to discover renames and
3733 3733 copies in the patch in the same way as :hg:`addremove`.
3734 3734
3735 3735 To read a patch from standard input, use "-" as the patch name. If
3736 3736 a URL is specified, the patch will be downloaded from it.
3737 3737 See :hg:`help dates` for a list of formats valid for -d/--date.
3738 3738
3739 3739 .. container:: verbose
3740 3740
3741 3741 Examples:
3742 3742
3743 3743 - import a traditional patch from a website and detect renames::
3744 3744
3745 3745 hg import -s 80 http://example.com/bugfix.patch
3746 3746
3747 3747 - import a changeset from an hgweb server::
3748 3748
3749 3749 hg import http://www.selenic.com/hg/rev/5ca8c111e9aa
3750 3750
3751 3751 - import all the patches in an Unix-style mbox::
3752 3752
3753 3753 hg import incoming-patches.mbox
3754 3754
3755 3755 - attempt to exactly restore an exported changeset (not always
3756 3756 possible)::
3757 3757
3758 3758 hg import --exact proposed-fix.patch
3759 3759
3760 3760 Returns 0 on success.
3761 3761 """
3762 3762
3763 3763 if not patch1:
3764 3764 raise util.Abort(_('need at least one patch to import'))
3765 3765
3766 3766 patches = (patch1,) + patches
3767 3767
3768 3768 date = opts.get('date')
3769 3769 if date:
3770 3770 opts['date'] = util.parsedate(date)
3771 3771
3772 3772 update = not opts.get('bypass')
3773 3773 if not update and opts.get('no_commit'):
3774 3774 raise util.Abort(_('cannot use --no-commit with --bypass'))
3775 3775 try:
3776 3776 sim = float(opts.get('similarity') or 0)
3777 3777 except ValueError:
3778 3778 raise util.Abort(_('similarity must be a number'))
3779 3779 if sim < 0 or sim > 100:
3780 3780 raise util.Abort(_('similarity must be between 0 and 100'))
3781 3781 if sim and not update:
3782 3782 raise util.Abort(_('cannot use --similarity with --bypass'))
3783 3783
3784 3784 if update:
3785 3785 cmdutil.checkunfinished(repo)
3786 3786 if (opts.get('exact') or not opts.get('force')) and update:
3787 3787 cmdutil.bailifchanged(repo)
3788 3788
3789 3789 base = opts["base"]
3790 3790 wlock = lock = tr = None
3791 3791 msgs = []
3792 3792
3793 3793
3794 3794 try:
3795 3795 try:
3796 3796 wlock = repo.wlock()
3797 3797 if not opts.get('no_commit'):
3798 3798 lock = repo.lock()
3799 3799 tr = repo.transaction('import')
3800 3800 parents = repo.parents()
3801 3801 for patchurl in patches:
3802 3802 if patchurl == '-':
3803 3803 ui.status(_('applying patch from stdin\n'))
3804 3804 patchfile = ui.fin
3805 3805 patchurl = 'stdin' # for error message
3806 3806 else:
3807 3807 patchurl = os.path.join(base, patchurl)
3808 3808 ui.status(_('applying %s\n') % patchurl)
3809 3809 patchfile = hg.openpath(ui, patchurl)
3810 3810
3811 3811 haspatch = False
3812 3812 for hunk in patch.split(patchfile):
3813 3813 (msg, node) = cmdutil.tryimportone(ui, repo, hunk, parents,
3814 3814 opts, msgs, hg.clean)
3815 3815 if msg:
3816 3816 haspatch = True
3817 3817 ui.note(msg + '\n')
3818 3818 if update or opts.get('exact'):
3819 3819 parents = repo.parents()
3820 3820 else:
3821 3821 parents = [repo[node]]
3822 3822
3823 3823 if not haspatch:
3824 3824 raise util.Abort(_('%s: no diffs found') % patchurl)
3825 3825
3826 3826 if tr:
3827 3827 tr.close()
3828 3828 if msgs:
3829 3829 repo.savecommitmessage('\n* * *\n'.join(msgs))
3830 3830 except: # re-raises
3831 3831 # wlock.release() indirectly calls dirstate.write(): since
3832 3832 # we're crashing, we do not want to change the working dir
3833 3833 # parent after all, so make sure it writes nothing
3834 3834 repo.dirstate.invalidate()
3835 3835 raise
3836 3836 finally:
3837 3837 if tr:
3838 3838 tr.release()
3839 3839 release(lock, wlock)
3840 3840
3841 3841 @command('incoming|in',
3842 3842 [('f', 'force', None,
3843 3843 _('run even if remote repository is unrelated')),
3844 3844 ('n', 'newest-first', None, _('show newest record first')),
3845 3845 ('', 'bundle', '',
3846 3846 _('file to store the bundles into'), _('FILE')),
3847 3847 ('r', 'rev', [], _('a remote changeset intended to be added'), _('REV')),
3848 3848 ('B', 'bookmarks', False, _("compare bookmarks")),
3849 3849 ('b', 'branch', [],
3850 3850 _('a specific branch you would like to pull'), _('BRANCH')),
3851 3851 ] + logopts + remoteopts + subrepoopts,
3852 3852 _('[-p] [-n] [-M] [-f] [-r REV]... [--bundle FILENAME] [SOURCE]'))
3853 3853 def incoming(ui, repo, source="default", **opts):
3854 3854 """show new changesets found in source
3855 3855
3856 3856 Show new changesets found in the specified path/URL or the default
3857 3857 pull location. These are the changesets that would have been pulled
3858 3858 if a pull at the time you issued this command.
3859 3859
3860 3860 For remote repository, using --bundle avoids downloading the
3861 3861 changesets twice if the incoming is followed by a pull.
3862 3862
3863 3863 See pull for valid source format details.
3864 3864
3865 3865 .. container:: verbose
3866 3866
3867 3867 Examples:
3868 3868
3869 3869 - show incoming changes with patches and full description::
3870 3870
3871 3871 hg incoming -vp
3872 3872
3873 3873 - show incoming changes excluding merges, store a bundle::
3874 3874
3875 3875 hg in -vpM --bundle incoming.hg
3876 3876 hg pull incoming.hg
3877 3877
3878 3878 - briefly list changes inside a bundle::
3879 3879
3880 3880 hg in changes.hg -T "{desc|firstline}\\n"
3881 3881
3882 3882 Returns 0 if there are incoming changes, 1 otherwise.
3883 3883 """
3884 3884 if opts.get('graph'):
3885 3885 cmdutil.checkunsupportedgraphflags([], opts)
3886 3886 def display(other, chlist, displayer):
3887 3887 revdag = cmdutil.graphrevs(other, chlist, opts)
3888 3888 showparents = [ctx.node() for ctx in repo[None].parents()]
3889 3889 cmdutil.displaygraph(ui, revdag, displayer, showparents,
3890 3890 graphmod.asciiedges)
3891 3891
3892 3892 hg._incoming(display, lambda: 1, ui, repo, source, opts, buffered=True)
3893 3893 return 0
3894 3894
3895 3895 if opts.get('bundle') and opts.get('subrepos'):
3896 3896 raise util.Abort(_('cannot combine --bundle and --subrepos'))
3897 3897
3898 3898 if opts.get('bookmarks'):
3899 3899 source, branches = hg.parseurl(ui.expandpath(source),
3900 3900 opts.get('branch'))
3901 3901 other = hg.peer(repo, opts, source)
3902 3902 if 'bookmarks' not in other.listkeys('namespaces'):
3903 3903 ui.warn(_("remote doesn't support bookmarks\n"))
3904 3904 return 0
3905 3905 ui.status(_('comparing with %s\n') % util.hidepassword(source))
3906 3906 return bookmarks.diff(ui, repo, other)
3907 3907
3908 3908 repo._subtoppath = ui.expandpath(source)
3909 3909 try:
3910 3910 return hg.incoming(ui, repo, source, opts)
3911 3911 finally:
3912 3912 del repo._subtoppath
3913 3913
3914 3914
3915 3915 @command('^init', remoteopts, _('[-e CMD] [--remotecmd CMD] [DEST]'))
3916 3916 def init(ui, dest=".", **opts):
3917 3917 """create a new repository in the given directory
3918 3918
3919 3919 Initialize a new repository in the given directory. If the given
3920 3920 directory does not exist, it will be created.
3921 3921
3922 3922 If no directory is given, the current directory is used.
3923 3923
3924 3924 It is possible to specify an ``ssh://`` URL as the destination.
3925 3925 See :hg:`help urls` for more information.
3926 3926
3927 3927 Returns 0 on success.
3928 3928 """
3929 3929 hg.peer(ui, opts, ui.expandpath(dest), create=True)
3930 3930
3931 3931 @command('locate',
3932 3932 [('r', 'rev', '', _('search the repository as it is in REV'), _('REV')),
3933 3933 ('0', 'print0', None, _('end filenames with NUL, for use with xargs')),
3934 3934 ('f', 'fullpath', None, _('print complete paths from the filesystem root')),
3935 3935 ] + walkopts,
3936 3936 _('[OPTION]... [PATTERN]...'))
3937 3937 def locate(ui, repo, *pats, **opts):
3938 3938 """locate files matching specific patterns
3939 3939
3940 3940 Print files under Mercurial control in the working directory whose
3941 3941 names match the given patterns.
3942 3942
3943 3943 By default, this command searches all directories in the working
3944 3944 directory. To search just the current directory and its
3945 3945 subdirectories, use "--include .".
3946 3946
3947 3947 If no patterns are given to match, this command prints the names
3948 3948 of all files under Mercurial control in the working directory.
3949 3949
3950 3950 If you want to feed the output of this command into the "xargs"
3951 3951 command, use the -0 option to both this command and "xargs". This
3952 3952 will avoid the problem of "xargs" treating single filenames that
3953 3953 contain whitespace as multiple filenames.
3954 3954
3955 3955 Returns 0 if a match is found, 1 otherwise.
3956 3956 """
3957 3957 end = opts.get('print0') and '\0' or '\n'
3958 3958 rev = scmutil.revsingle(repo, opts.get('rev'), None).node()
3959 3959
3960 3960 ret = 1
3961 3961 m = scmutil.match(repo[rev], pats, opts, default='relglob')
3962 3962 m.bad = lambda x, y: False
3963 3963 for abs in repo[rev].walk(m):
3964 3964 if not rev and abs not in repo.dirstate:
3965 3965 continue
3966 3966 if opts.get('fullpath'):
3967 3967 ui.write(repo.wjoin(abs), end)
3968 3968 else:
3969 3969 ui.write(((pats and m.rel(abs)) or abs), end)
3970 3970 ret = 0
3971 3971
3972 3972 return ret
3973 3973
3974 3974 @command('^log|history',
3975 3975 [('f', 'follow', None,
3976 3976 _('follow changeset history, or file history across copies and renames')),
3977 3977 ('', 'follow-first', None,
3978 3978 _('only follow the first parent of merge changesets (DEPRECATED)')),
3979 3979 ('d', 'date', '', _('show revisions matching date spec'), _('DATE')),
3980 3980 ('C', 'copies', None, _('show copied files')),
3981 3981 ('k', 'keyword', [],
3982 3982 _('do case-insensitive search for a given text'), _('TEXT')),
3983 3983 ('r', 'rev', [], _('show the specified revision or range'), _('REV')),
3984 3984 ('', 'removed', None, _('include revisions where files were removed')),
3985 3985 ('m', 'only-merges', None, _('show only merges (DEPRECATED)')),
3986 3986 ('u', 'user', [], _('revisions committed by user'), _('USER')),
3987 3987 ('', 'only-branch', [],
3988 3988 _('show only changesets within the given named branch (DEPRECATED)'),
3989 3989 _('BRANCH')),
3990 3990 ('b', 'branch', [],
3991 3991 _('show changesets within the given named branch'), _('BRANCH')),
3992 3992 ('P', 'prune', [],
3993 3993 _('do not display revision or any of its ancestors'), _('REV')),
3994 3994 ] + logopts + walkopts,
3995 3995 _('[OPTION]... [FILE]'))
3996 3996 def log(ui, repo, *pats, **opts):
3997 3997 """show revision history of entire repository or files
3998 3998
3999 3999 Print the revision history of the specified files or the entire
4000 4000 project.
4001 4001
4002 4002 If no revision range is specified, the default is ``tip:0`` unless
4003 4003 --follow is set, in which case the working directory parent is
4004 4004 used as the starting revision.
4005 4005
4006 4006 File history is shown without following rename or copy history of
4007 4007 files. Use -f/--follow with a filename to follow history across
4008 4008 renames and copies. --follow without a filename will only show
4009 4009 ancestors or descendants of the starting revision.
4010 4010
4011 4011 By default this command prints revision number and changeset id,
4012 4012 tags, non-trivial parents, user, date and time, and a summary for
4013 4013 each commit. When the -v/--verbose switch is used, the list of
4014 4014 changed files and full commit message are shown.
4015 4015
4016 4016 With --graph the revisions are shown as an ASCII art DAG with the most
4017 4017 recent changeset at the top.
4018 4018 'o' is a changeset, '@' is a working directory parent, 'x' is obsolete,
4019 4019 and '+' represents a fork where the changeset from the lines below is a
4020 4020 parent of the 'o' merge on the same line.
4021 4021
4022 4022 .. note::
4023 4023
4024 4024 log -p/--patch may generate unexpected diff output for merge
4025 4025 changesets, as it will only compare the merge changeset against
4026 4026 its first parent. Also, only files different from BOTH parents
4027 4027 will appear in files:.
4028 4028
4029 4029 .. note::
4030 4030
4031 4031 for performance reasons, log FILE may omit duplicate changes
4032 4032 made on branches and will not show deletions. To see all
4033 4033 changes including duplicates and deletions, use the --removed
4034 4034 switch.
4035 4035
4036 4036 .. container:: verbose
4037 4037
4038 4038 Some examples:
4039 4039
4040 4040 - changesets with full descriptions and file lists::
4041 4041
4042 4042 hg log -v
4043 4043
4044 4044 - changesets ancestral to the working directory::
4045 4045
4046 4046 hg log -f
4047 4047
4048 4048 - last 10 commits on the current branch::
4049 4049
4050 4050 hg log -l 10 -b .
4051 4051
4052 4052 - changesets showing all modifications of a file, including removals::
4053 4053
4054 4054 hg log --removed file.c
4055 4055
4056 4056 - all changesets that touch a directory, with diffs, excluding merges::
4057 4057
4058 4058 hg log -Mp lib/
4059 4059
4060 4060 - all revision numbers that match a keyword::
4061 4061
4062 4062 hg log -k bug --template "{rev}\\n"
4063 4063
4064 4064 - check if a given changeset is included is a tagged release::
4065 4065
4066 4066 hg log -r "a21ccf and ancestor(1.9)"
4067 4067
4068 4068 - find all changesets by some user in a date range::
4069 4069
4070 4070 hg log -k alice -d "may 2008 to jul 2008"
4071 4071
4072 4072 - summary of all changesets after the last tag::
4073 4073
4074 4074 hg log -r "last(tagged())::" --template "{desc|firstline}\\n"
4075 4075
4076 4076 See :hg:`help dates` for a list of formats valid for -d/--date.
4077 4077
4078 4078 See :hg:`help revisions` and :hg:`help revsets` for more about
4079 4079 specifying revisions.
4080 4080
4081 4081 See :hg:`help templates` for more about pre-packaged styles and
4082 4082 specifying custom templates.
4083 4083
4084 4084 Returns 0 on success.
4085 4085 """
4086 4086 if opts.get('graph'):
4087 4087 return cmdutil.graphlog(ui, repo, *pats, **opts)
4088 4088
4089 4089 revs, expr, filematcher = cmdutil.getlogrevs(repo, pats, opts)
4090 4090 limit = cmdutil.loglimit(opts)
4091 4091 count = 0
4092 4092
4093 4093 getrenamed = None
4094 4094 if opts.get('copies'):
4095 4095 endrev = None
4096 4096 if opts.get('rev'):
4097 4097 endrev = scmutil.revrange(repo, opts.get('rev')).max() + 1
4098 4098 getrenamed = templatekw.getrenamedfn(repo, endrev=endrev)
4099 4099
4100 4100 displayer = cmdutil.show_changeset(ui, repo, opts, buffered=True)
4101 4101 for rev in revs:
4102 4102 if count == limit:
4103 4103 break
4104 4104 ctx = repo[rev]
4105 4105 copies = None
4106 4106 if getrenamed is not None and rev:
4107 4107 copies = []
4108 4108 for fn in ctx.files():
4109 4109 rename = getrenamed(fn, rev)
4110 4110 if rename:
4111 4111 copies.append((fn, rename[0]))
4112 4112 revmatchfn = filematcher and filematcher(ctx.rev()) or None
4113 4113 displayer.show(ctx, copies=copies, matchfn=revmatchfn)
4114 4114 if displayer.flush(rev):
4115 4115 count += 1
4116 4116
4117 4117 displayer.close()
4118 4118
4119 4119 @command('manifest',
4120 4120 [('r', 'rev', '', _('revision to display'), _('REV')),
4121 4121 ('', 'all', False, _("list files from all revisions"))],
4122 4122 _('[-r REV]'))
4123 4123 def manifest(ui, repo, node=None, rev=None, **opts):
4124 4124 """output the current or given revision of the project manifest
4125 4125
4126 4126 Print a list of version controlled files for the given revision.
4127 4127 If no revision is given, the first parent of the working directory
4128 4128 is used, or the null revision if no revision is checked out.
4129 4129
4130 4130 With -v, print file permissions, symlink and executable bits.
4131 4131 With --debug, print file revision hashes.
4132 4132
4133 4133 If option --all is specified, the list of all files from all revisions
4134 4134 is printed. This includes deleted and renamed files.
4135 4135
4136 4136 Returns 0 on success.
4137 4137 """
4138 4138
4139 4139 fm = ui.formatter('manifest', opts)
4140 4140
4141 4141 if opts.get('all'):
4142 4142 if rev or node:
4143 4143 raise util.Abort(_("can't specify a revision with --all"))
4144 4144
4145 4145 res = []
4146 4146 prefix = "data/"
4147 4147 suffix = ".i"
4148 4148 plen = len(prefix)
4149 4149 slen = len(suffix)
4150 4150 lock = repo.lock()
4151 4151 try:
4152 4152 for fn, b, size in repo.store.datafiles():
4153 4153 if size != 0 and fn[-slen:] == suffix and fn[:plen] == prefix:
4154 4154 res.append(fn[plen:-slen])
4155 4155 finally:
4156 4156 lock.release()
4157 4157 for f in res:
4158 4158 fm.startitem()
4159 4159 fm.write("path", '%s\n', f)
4160 4160 fm.end()
4161 4161 return
4162 4162
4163 4163 if rev and node:
4164 4164 raise util.Abort(_("please specify just one revision"))
4165 4165
4166 4166 if not node:
4167 4167 node = rev
4168 4168
4169 4169 char = {'l': '@', 'x': '*', '': ''}
4170 4170 mode = {'l': '644', 'x': '755', '': '644'}
4171 4171 ctx = scmutil.revsingle(repo, node)
4172 4172 mf = ctx.manifest()
4173 4173 for f in ctx:
4174 4174 fm.startitem()
4175 4175 fl = ctx[f].flags()
4176 4176 fm.condwrite(ui.debugflag, 'hash', '%s ', hex(mf[f]))
4177 4177 fm.condwrite(ui.verbose, 'mode type', '%s %1s ', mode[fl], char[fl])
4178 4178 fm.write('path', '%s\n', f)
4179 4179 fm.end()
4180 4180
4181 4181 @command('^merge',
4182 4182 [('f', 'force', None,
4183 4183 _('force a merge including outstanding changes (DEPRECATED)')),
4184 4184 ('r', 'rev', '', _('revision to merge'), _('REV')),
4185 4185 ('P', 'preview', None,
4186 4186 _('review revisions to merge (no merge is performed)'))
4187 4187 ] + mergetoolopts,
4188 4188 _('[-P] [-f] [[-r] REV]'))
4189 4189 def merge(ui, repo, node=None, **opts):
4190 4190 """merge working directory with another revision
4191 4191
4192 4192 The current working directory is updated with all changes made in
4193 4193 the requested revision since the last common predecessor revision.
4194 4194
4195 4195 Files that changed between either parent are marked as changed for
4196 4196 the next commit and a commit must be performed before any further
4197 4197 updates to the repository are allowed. The next commit will have
4198 4198 two parents.
4199 4199
4200 4200 ``--tool`` can be used to specify the merge tool used for file
4201 4201 merges. It overrides the HGMERGE environment variable and your
4202 4202 configuration files. See :hg:`help merge-tools` for options.
4203 4203
4204 4204 If no revision is specified, the working directory's parent is a
4205 4205 head revision, and the current branch contains exactly one other
4206 4206 head, the other head is merged with by default. Otherwise, an
4207 4207 explicit revision with which to merge with must be provided.
4208 4208
4209 4209 :hg:`resolve` must be used to resolve unresolved files.
4210 4210
4211 4211 To undo an uncommitted merge, use :hg:`update --clean .` which
4212 4212 will check out a clean copy of the original merge parent, losing
4213 4213 all changes.
4214 4214
4215 4215 Returns 0 on success, 1 if there are unresolved files.
4216 4216 """
4217 4217
4218 4218 if opts.get('rev') and node:
4219 4219 raise util.Abort(_("please specify just one revision"))
4220 4220 if not node:
4221 4221 node = opts.get('rev')
4222 4222
4223 4223 if node:
4224 4224 node = scmutil.revsingle(repo, node).node()
4225 4225
4226 4226 if not node and repo._bookmarkcurrent:
4227 4227 bmheads = repo.bookmarkheads(repo._bookmarkcurrent)
4228 4228 curhead = repo[repo._bookmarkcurrent].node()
4229 4229 if len(bmheads) == 2:
4230 4230 if curhead == bmheads[0]:
4231 4231 node = bmheads[1]
4232 4232 else:
4233 4233 node = bmheads[0]
4234 4234 elif len(bmheads) > 2:
4235 4235 raise util.Abort(_("multiple matching bookmarks to merge - "
4236 4236 "please merge with an explicit rev or bookmark"),
4237 4237 hint=_("run 'hg heads' to see all heads"))
4238 4238 elif len(bmheads) <= 1:
4239 4239 raise util.Abort(_("no matching bookmark to merge - "
4240 4240 "please merge with an explicit rev or bookmark"),
4241 4241 hint=_("run 'hg heads' to see all heads"))
4242 4242
4243 4243 if not node and not repo._bookmarkcurrent:
4244 4244 branch = repo[None].branch()
4245 4245 bheads = repo.branchheads(branch)
4246 4246 nbhs = [bh for bh in bheads if not repo[bh].bookmarks()]
4247 4247
4248 4248 if len(nbhs) > 2:
4249 4249 raise util.Abort(_("branch '%s' has %d heads - "
4250 4250 "please merge with an explicit rev")
4251 4251 % (branch, len(bheads)),
4252 4252 hint=_("run 'hg heads .' to see heads"))
4253 4253
4254 4254 parent = repo.dirstate.p1()
4255 4255 if len(nbhs) <= 1:
4256 4256 if len(bheads) > 1:
4257 4257 raise util.Abort(_("heads are bookmarked - "
4258 4258 "please merge with an explicit rev"),
4259 4259 hint=_("run 'hg heads' to see all heads"))
4260 4260 if len(repo.heads()) > 1:
4261 4261 raise util.Abort(_("branch '%s' has one head - "
4262 4262 "please merge with an explicit rev")
4263 4263 % branch,
4264 4264 hint=_("run 'hg heads' to see all heads"))
4265 4265 msg, hint = _('nothing to merge'), None
4266 4266 if parent != repo.lookup(branch):
4267 4267 hint = _("use 'hg update' instead")
4268 4268 raise util.Abort(msg, hint=hint)
4269 4269
4270 4270 if parent not in bheads:
4271 4271 raise util.Abort(_('working directory not at a head revision'),
4272 4272 hint=_("use 'hg update' or merge with an "
4273 4273 "explicit revision"))
4274 4274 if parent == nbhs[0]:
4275 4275 node = nbhs[-1]
4276 4276 else:
4277 4277 node = nbhs[0]
4278 4278
4279 4279 if opts.get('preview'):
4280 4280 # find nodes that are ancestors of p2 but not of p1
4281 4281 p1 = repo.lookup('.')
4282 4282 p2 = repo.lookup(node)
4283 4283 nodes = repo.changelog.findmissing(common=[p1], heads=[p2])
4284 4284
4285 4285 displayer = cmdutil.show_changeset(ui, repo, opts)
4286 4286 for node in nodes:
4287 4287 displayer.show(repo[node])
4288 4288 displayer.close()
4289 4289 return 0
4290 4290
4291 4291 try:
4292 4292 # ui.forcemerge is an internal variable, do not document
4293 4293 repo.ui.setconfig('ui', 'forcemerge', opts.get('tool', ''), 'merge')
4294 4294 return hg.merge(repo, node, force=opts.get('force'))
4295 4295 finally:
4296 4296 ui.setconfig('ui', 'forcemerge', '', 'merge')
4297 4297
4298 4298 @command('outgoing|out',
4299 4299 [('f', 'force', None, _('run even when the destination is unrelated')),
4300 4300 ('r', 'rev', [],
4301 4301 _('a changeset intended to be included in the destination'), _('REV')),
4302 4302 ('n', 'newest-first', None, _('show newest record first')),
4303 4303 ('B', 'bookmarks', False, _('compare bookmarks')),
4304 4304 ('b', 'branch', [], _('a specific branch you would like to push'),
4305 4305 _('BRANCH')),
4306 4306 ] + logopts + remoteopts + subrepoopts,
4307 4307 _('[-M] [-p] [-n] [-f] [-r REV]... [DEST]'))
4308 4308 def outgoing(ui, repo, dest=None, **opts):
4309 4309 """show changesets not found in the destination
4310 4310
4311 4311 Show changesets not found in the specified destination repository
4312 4312 or the default push location. These are the changesets that would
4313 4313 be pushed if a push was requested.
4314 4314
4315 4315 See pull for details of valid destination formats.
4316 4316
4317 4317 Returns 0 if there are outgoing changes, 1 otherwise.
4318 4318 """
4319 4319 if opts.get('graph'):
4320 4320 cmdutil.checkunsupportedgraphflags([], opts)
4321 4321 o, other = hg._outgoing(ui, repo, dest, opts)
4322 4322 if not o:
4323 4323 cmdutil.outgoinghooks(ui, repo, other, opts, o)
4324 4324 return
4325 4325
4326 4326 revdag = cmdutil.graphrevs(repo, o, opts)
4327 4327 displayer = cmdutil.show_changeset(ui, repo, opts, buffered=True)
4328 4328 showparents = [ctx.node() for ctx in repo[None].parents()]
4329 4329 cmdutil.displaygraph(ui, revdag, displayer, showparents,
4330 4330 graphmod.asciiedges)
4331 4331 cmdutil.outgoinghooks(ui, repo, other, opts, o)
4332 4332 return 0
4333 4333
4334 4334 if opts.get('bookmarks'):
4335 4335 dest = ui.expandpath(dest or 'default-push', dest or 'default')
4336 4336 dest, branches = hg.parseurl(dest, opts.get('branch'))
4337 4337 other = hg.peer(repo, opts, dest)
4338 4338 if 'bookmarks' not in other.listkeys('namespaces'):
4339 4339 ui.warn(_("remote doesn't support bookmarks\n"))
4340 4340 return 0
4341 4341 ui.status(_('comparing with %s\n') % util.hidepassword(dest))
4342 4342 return bookmarks.diff(ui, other, repo)
4343 4343
4344 4344 repo._subtoppath = ui.expandpath(dest or 'default-push', dest or 'default')
4345 4345 try:
4346 4346 return hg.outgoing(ui, repo, dest, opts)
4347 4347 finally:
4348 4348 del repo._subtoppath
4349 4349
4350 4350 @command('parents',
4351 4351 [('r', 'rev', '', _('show parents of the specified revision'), _('REV')),
4352 4352 ] + templateopts,
4353 4353 _('[-r REV] [FILE]'))
4354 4354 def parents(ui, repo, file_=None, **opts):
4355 4355 """show the parents of the working directory or revision
4356 4356
4357 4357 Print the working directory's parent revisions. If a revision is
4358 4358 given via -r/--rev, the parent of that revision will be printed.
4359 4359 If a file argument is given, the revision in which the file was
4360 4360 last changed (before the working directory revision or the
4361 4361 argument to --rev if given) is printed.
4362 4362
4363 4363 Returns 0 on success.
4364 4364 """
4365 4365
4366 4366 ctx = scmutil.revsingle(repo, opts.get('rev'), None)
4367 4367
4368 4368 if file_:
4369 4369 m = scmutil.match(ctx, (file_,), opts)
4370 4370 if m.anypats() or len(m.files()) != 1:
4371 4371 raise util.Abort(_('can only specify an explicit filename'))
4372 4372 file_ = m.files()[0]
4373 4373 filenodes = []
4374 4374 for cp in ctx.parents():
4375 4375 if not cp:
4376 4376 continue
4377 4377 try:
4378 4378 filenodes.append(cp.filenode(file_))
4379 4379 except error.LookupError:
4380 4380 pass
4381 4381 if not filenodes:
4382 4382 raise util.Abort(_("'%s' not found in manifest!") % file_)
4383 4383 p = []
4384 4384 for fn in filenodes:
4385 4385 fctx = repo.filectx(file_, fileid=fn)
4386 4386 p.append(fctx.node())
4387 4387 else:
4388 4388 p = [cp.node() for cp in ctx.parents()]
4389 4389
4390 4390 displayer = cmdutil.show_changeset(ui, repo, opts)
4391 4391 for n in p:
4392 4392 if n != nullid:
4393 4393 displayer.show(repo[n])
4394 4394 displayer.close()
4395 4395
4396 4396 @command('paths', [], _('[NAME]'))
4397 4397 def paths(ui, repo, search=None):
4398 4398 """show aliases for remote repositories
4399 4399
4400 4400 Show definition of symbolic path name NAME. If no name is given,
4401 4401 show definition of all available names.
4402 4402
4403 4403 Option -q/--quiet suppresses all output when searching for NAME
4404 4404 and shows only the path names when listing all definitions.
4405 4405
4406 4406 Path names are defined in the [paths] section of your
4407 4407 configuration file and in ``/etc/mercurial/hgrc``. If run inside a
4408 4408 repository, ``.hg/hgrc`` is used, too.
4409 4409
4410 4410 The path names ``default`` and ``default-push`` have a special
4411 4411 meaning. When performing a push or pull operation, they are used
4412 4412 as fallbacks if no location is specified on the command-line.
4413 4413 When ``default-push`` is set, it will be used for push and
4414 4414 ``default`` will be used for pull; otherwise ``default`` is used
4415 4415 as the fallback for both. When cloning a repository, the clone
4416 4416 source is written as ``default`` in ``.hg/hgrc``. Note that
4417 4417 ``default`` and ``default-push`` apply to all inbound (e.g.
4418 4418 :hg:`incoming`) and outbound (e.g. :hg:`outgoing`, :hg:`email` and
4419 4419 :hg:`bundle`) operations.
4420 4420
4421 4421 See :hg:`help urls` for more information.
4422 4422
4423 4423 Returns 0 on success.
4424 4424 """
4425 4425 if search:
4426 4426 for name, path in ui.configitems("paths"):
4427 4427 if name == search:
4428 4428 ui.status("%s\n" % util.hidepassword(path))
4429 4429 return
4430 4430 if not ui.quiet:
4431 4431 ui.warn(_("not found!\n"))
4432 4432 return 1
4433 4433 else:
4434 4434 for name, path in ui.configitems("paths"):
4435 4435 if ui.quiet:
4436 4436 ui.write("%s\n" % name)
4437 4437 else:
4438 4438 ui.write("%s = %s\n" % (name, util.hidepassword(path)))
4439 4439
4440 4440 @command('phase',
4441 4441 [('p', 'public', False, _('set changeset phase to public')),
4442 4442 ('d', 'draft', False, _('set changeset phase to draft')),
4443 4443 ('s', 'secret', False, _('set changeset phase to secret')),
4444 4444 ('f', 'force', False, _('allow to move boundary backward')),
4445 4445 ('r', 'rev', [], _('target revision'), _('REV')),
4446 4446 ],
4447 4447 _('[-p|-d|-s] [-f] [-r] REV...'))
4448 4448 def phase(ui, repo, *revs, **opts):
4449 4449 """set or show the current phase name
4450 4450
4451 4451 With no argument, show the phase name of specified revisions.
4452 4452
4453 4453 With one of -p/--public, -d/--draft or -s/--secret, change the
4454 4454 phase value of the specified revisions.
4455 4455
4456 4456 Unless -f/--force is specified, :hg:`phase` won't move changeset from a
4457 4457 lower phase to an higher phase. Phases are ordered as follows::
4458 4458
4459 4459 public < draft < secret
4460 4460
4461 4461 Returns 0 on success, 1 if no phases were changed or some could not
4462 4462 be changed.
4463 4463 """
4464 4464 # search for a unique phase argument
4465 4465 targetphase = None
4466 4466 for idx, name in enumerate(phases.phasenames):
4467 4467 if opts[name]:
4468 4468 if targetphase is not None:
4469 4469 raise util.Abort(_('only one phase can be specified'))
4470 4470 targetphase = idx
4471 4471
4472 4472 # look for specified revision
4473 4473 revs = list(revs)
4474 4474 revs.extend(opts['rev'])
4475 4475 if not revs:
4476 4476 raise util.Abort(_('no revisions specified'))
4477 4477
4478 4478 revs = scmutil.revrange(repo, revs)
4479 4479
4480 4480 lock = None
4481 4481 ret = 0
4482 4482 if targetphase is None:
4483 4483 # display
4484 4484 for r in revs:
4485 4485 ctx = repo[r]
4486 4486 ui.write('%i: %s\n' % (ctx.rev(), ctx.phasestr()))
4487 4487 else:
4488 4488 lock = repo.lock()
4489 4489 try:
4490 4490 # set phase
4491 4491 if not revs:
4492 4492 raise util.Abort(_('empty revision set'))
4493 4493 nodes = [repo[r].node() for r in revs]
4494 4494 olddata = repo._phasecache.getphaserevs(repo)[:]
4495 4495 phases.advanceboundary(repo, targetphase, nodes)
4496 4496 if opts['force']:
4497 4497 phases.retractboundary(repo, targetphase, nodes)
4498 4498 finally:
4499 4499 lock.release()
4500 4500 # moving revision from public to draft may hide them
4501 4501 # We have to check result on an unfiltered repository
4502 4502 unfi = repo.unfiltered()
4503 4503 newdata = repo._phasecache.getphaserevs(unfi)
4504 4504 changes = sum(o != newdata[i] for i, o in enumerate(olddata))
4505 4505 cl = unfi.changelog
4506 4506 rejected = [n for n in nodes
4507 4507 if newdata[cl.rev(n)] < targetphase]
4508 4508 if rejected:
4509 4509 ui.warn(_('cannot move %i changesets to a higher '
4510 4510 'phase, use --force\n') % len(rejected))
4511 4511 ret = 1
4512 4512 if changes:
4513 4513 msg = _('phase changed for %i changesets\n') % changes
4514 4514 if ret:
4515 4515 ui.status(msg)
4516 4516 else:
4517 4517 ui.note(msg)
4518 4518 else:
4519 4519 ui.warn(_('no phases changed\n'))
4520 4520 ret = 1
4521 4521 return ret
4522 4522
4523 4523 def postincoming(ui, repo, modheads, optupdate, checkout):
4524 4524 if modheads == 0:
4525 4525 return
4526 4526 if optupdate:
4527 4527 checkout, movemarkfrom = bookmarks.calculateupdate(ui, repo, checkout)
4528 4528 try:
4529 4529 ret = hg.update(repo, checkout)
4530 4530 except util.Abort, inst:
4531 4531 ui.warn(_("not updating: %s\n") % str(inst))
4532 4532 if inst.hint:
4533 4533 ui.warn(_("(%s)\n") % inst.hint)
4534 4534 return 0
4535 4535 if not ret and not checkout:
4536 4536 if bookmarks.update(repo, [movemarkfrom], repo['.'].node()):
4537 4537 ui.status(_("updating bookmark %s\n") % repo._bookmarkcurrent)
4538 4538 return ret
4539 4539 if modheads > 1:
4540 4540 currentbranchheads = len(repo.branchheads())
4541 4541 if currentbranchheads == modheads:
4542 4542 ui.status(_("(run 'hg heads' to see heads, 'hg merge' to merge)\n"))
4543 4543 elif currentbranchheads > 1:
4544 4544 ui.status(_("(run 'hg heads .' to see heads, 'hg merge' to "
4545 4545 "merge)\n"))
4546 4546 else:
4547 4547 ui.status(_("(run 'hg heads' to see heads)\n"))
4548 4548 else:
4549 4549 ui.status(_("(run 'hg update' to get a working copy)\n"))
4550 4550
4551 4551 @command('^pull',
4552 4552 [('u', 'update', None,
4553 4553 _('update to new branch head if changesets were pulled')),
4554 4554 ('f', 'force', None, _('run even when remote repository is unrelated')),
4555 4555 ('r', 'rev', [], _('a remote changeset intended to be added'), _('REV')),
4556 4556 ('B', 'bookmark', [], _("bookmark to pull"), _('BOOKMARK')),
4557 4557 ('b', 'branch', [], _('a specific branch you would like to pull'),
4558 4558 _('BRANCH')),
4559 4559 ] + remoteopts,
4560 4560 _('[-u] [-f] [-r REV]... [-e CMD] [--remotecmd CMD] [SOURCE]'))
4561 4561 def pull(ui, repo, source="default", **opts):
4562 4562 """pull changes from the specified source
4563 4563
4564 4564 Pull changes from a remote repository to a local one.
4565 4565
4566 4566 This finds all changes from the repository at the specified path
4567 4567 or URL and adds them to a local repository (the current one unless
4568 4568 -R is specified). By default, this does not update the copy of the
4569 4569 project in the working directory.
4570 4570
4571 4571 Use :hg:`incoming` if you want to see what would have been added
4572 4572 by a pull at the time you issued this command. If you then decide
4573 4573 to add those changes to the repository, you should use :hg:`pull
4574 4574 -r X` where ``X`` is the last changeset listed by :hg:`incoming`.
4575 4575
4576 4576 If SOURCE is omitted, the 'default' path will be used.
4577 4577 See :hg:`help urls` for more information.
4578 4578
4579 4579 Returns 0 on success, 1 if an update had unresolved files.
4580 4580 """
4581 4581 source, branches = hg.parseurl(ui.expandpath(source), opts.get('branch'))
4582 4582 other = hg.peer(repo, opts, source)
4583 4583 try:
4584 4584 ui.status(_('pulling from %s\n') % util.hidepassword(source))
4585 4585 revs, checkout = hg.addbranchrevs(repo, other, branches,
4586 4586 opts.get('rev'))
4587 4587
4588 4588 remotebookmarks = other.listkeys('bookmarks')
4589 4589
4590 4590 if opts.get('bookmark'):
4591 4591 if not revs:
4592 4592 revs = []
4593 4593 for b in opts['bookmark']:
4594 4594 if b not in remotebookmarks:
4595 4595 raise util.Abort(_('remote bookmark %s not found!') % b)
4596 4596 revs.append(remotebookmarks[b])
4597 4597
4598 4598 if revs:
4599 4599 try:
4600 4600 revs = [other.lookup(rev) for rev in revs]
4601 4601 except error.CapabilityError:
4602 4602 err = _("other repository doesn't support revision lookup, "
4603 4603 "so a rev cannot be specified.")
4604 4604 raise util.Abort(err)
4605 4605
4606 4606 modheads = repo.pull(other, heads=revs, force=opts.get('force'))
4607 4607 bookmarks.updatefromremote(ui, repo, remotebookmarks, source)
4608 4608 if checkout:
4609 4609 checkout = str(repo.changelog.rev(other.lookup(checkout)))
4610 4610 repo._subtoppath = source
4611 4611 try:
4612 4612 ret = postincoming(ui, repo, modheads, opts.get('update'), checkout)
4613 4613
4614 4614 finally:
4615 4615 del repo._subtoppath
4616 4616
4617 4617 # update specified bookmarks
4618 4618 if opts.get('bookmark'):
4619 4619 marks = repo._bookmarks
4620 4620 for b in opts['bookmark']:
4621 4621 # explicit pull overrides local bookmark if any
4622 4622 ui.status(_("importing bookmark %s\n") % b)
4623 4623 marks[b] = repo[remotebookmarks[b]].node()
4624 4624 marks.write()
4625 4625 finally:
4626 4626 other.close()
4627 4627 return ret
4628 4628
4629 4629 @command('^push',
4630 4630 [('f', 'force', None, _('force push')),
4631 4631 ('r', 'rev', [],
4632 4632 _('a changeset intended to be included in the destination'),
4633 4633 _('REV')),
4634 4634 ('B', 'bookmark', [], _("bookmark to push"), _('BOOKMARK')),
4635 4635 ('b', 'branch', [],
4636 4636 _('a specific branch you would like to push'), _('BRANCH')),
4637 4637 ('', 'new-branch', False, _('allow pushing a new branch')),
4638 4638 ] + remoteopts,
4639 4639 _('[-f] [-r REV]... [-e CMD] [--remotecmd CMD] [DEST]'))
4640 4640 def push(ui, repo, dest=None, **opts):
4641 4641 """push changes to the specified destination
4642 4642
4643 4643 Push changesets from the local repository to the specified
4644 4644 destination.
4645 4645
4646 4646 This operation is symmetrical to pull: it is identical to a pull
4647 4647 in the destination repository from the current one.
4648 4648
4649 4649 By default, push will not allow creation of new heads at the
4650 4650 destination, since multiple heads would make it unclear which head
4651 4651 to use. In this situation, it is recommended to pull and merge
4652 4652 before pushing.
4653 4653
4654 4654 Use --new-branch if you want to allow push to create a new named
4655 4655 branch that is not present at the destination. This allows you to
4656 4656 only create a new branch without forcing other changes.
4657 4657
4658 4658 .. note::
4659 4659
4660 4660 Extra care should be taken with the -f/--force option,
4661 4661 which will push all new heads on all branches, an action which will
4662 4662 almost always cause confusion for collaborators.
4663 4663
4664 4664 If -r/--rev is used, the specified revision and all its ancestors
4665 4665 will be pushed to the remote repository.
4666 4666
4667 4667 If -B/--bookmark is used, the specified bookmarked revision, its
4668 4668 ancestors, and the bookmark will be pushed to the remote
4669 4669 repository.
4670 4670
4671 4671 Please see :hg:`help urls` for important details about ``ssh://``
4672 4672 URLs. If DESTINATION is omitted, a default path will be used.
4673 4673
4674 4674 Returns 0 if push was successful, 1 if nothing to push.
4675 4675 """
4676 4676
4677 4677 if opts.get('bookmark'):
4678 4678 ui.setconfig('bookmarks', 'pushing', opts['bookmark'], 'push')
4679 4679 for b in opts['bookmark']:
4680 4680 # translate -B options to -r so changesets get pushed
4681 4681 if b in repo._bookmarks:
4682 4682 opts.setdefault('rev', []).append(b)
4683 4683 else:
4684 4684 # if we try to push a deleted bookmark, translate it to null
4685 4685 # this lets simultaneous -r, -b options continue working
4686 4686 opts.setdefault('rev', []).append("null")
4687 4687
4688 4688 dest = ui.expandpath(dest or 'default-push', dest or 'default')
4689 4689 dest, branches = hg.parseurl(dest, opts.get('branch'))
4690 4690 ui.status(_('pushing to %s\n') % util.hidepassword(dest))
4691 4691 revs, checkout = hg.addbranchrevs(repo, repo, branches, opts.get('rev'))
4692 4692 try:
4693 4693 other = hg.peer(repo, opts, dest)
4694 4694 except error.RepoError:
4695 4695 if dest == "default-push":
4696 4696 raise util.Abort(_("default repository not configured!"),
4697 4697 hint=_('see the "path" section in "hg help config"'))
4698 4698 else:
4699 4699 raise
4700 4700
4701 4701 if revs:
4702 4702 revs = [repo.lookup(r) for r in scmutil.revrange(repo, revs)]
4703 4703
4704 4704 repo._subtoppath = dest
4705 4705 try:
4706 4706 # push subrepos depth-first for coherent ordering
4707 4707 c = repo['']
4708 4708 subs = c.substate # only repos that are committed
4709 4709 for s in sorted(subs):
4710 4710 result = c.sub(s).push(opts)
4711 4711 if result == 0:
4712 4712 return not result
4713 4713 finally:
4714 4714 del repo._subtoppath
4715 4715 result = repo.push(other, opts.get('force'), revs=revs,
4716 4716 newbranch=opts.get('new_branch'))
4717 4717
4718 4718 result = not result
4719 4719
4720 4720 if opts.get('bookmark'):
4721 4721 bresult = bookmarks.pushtoremote(ui, repo, other, opts['bookmark'])
4722 4722 if bresult == 2:
4723 4723 return 2
4724 4724 if not result and bresult:
4725 4725 result = 2
4726 4726
4727 4727 return result
4728 4728
4729 4729 @command('recover', [])
4730 4730 def recover(ui, repo):
4731 4731 """roll back an interrupted transaction
4732 4732
4733 4733 Recover from an interrupted commit or pull.
4734 4734
4735 4735 This command tries to fix the repository status after an
4736 4736 interrupted operation. It should only be necessary when Mercurial
4737 4737 suggests it.
4738 4738
4739 4739 Returns 0 if successful, 1 if nothing to recover or verify fails.
4740 4740 """
4741 4741 if repo.recover():
4742 4742 return hg.verify(repo)
4743 4743 return 1
4744 4744
4745 4745 @command('^remove|rm',
4746 4746 [('A', 'after', None, _('record delete for missing files')),
4747 4747 ('f', 'force', None,
4748 4748 _('remove (and delete) file even if added or modified')),
4749 4749 ] + walkopts,
4750 4750 _('[OPTION]... FILE...'))
4751 4751 def remove(ui, repo, *pats, **opts):
4752 4752 """remove the specified files on the next commit
4753 4753
4754 4754 Schedule the indicated files for removal from the current branch.
4755 4755
4756 4756 This command schedules the files to be removed at the next commit.
4757 4757 To undo a remove before that, see :hg:`revert`. To undo added
4758 4758 files, see :hg:`forget`.
4759 4759
4760 4760 .. container:: verbose
4761 4761
4762 4762 -A/--after can be used to remove only files that have already
4763 4763 been deleted, -f/--force can be used to force deletion, and -Af
4764 4764 can be used to remove files from the next revision without
4765 4765 deleting them from the working directory.
4766 4766
4767 4767 The following table details the behavior of remove for different
4768 4768 file states (columns) and option combinations (rows). The file
4769 4769 states are Added [A], Clean [C], Modified [M] and Missing [!]
4770 4770 (as reported by :hg:`status`). The actions are Warn, Remove
4771 4771 (from branch) and Delete (from disk):
4772 4772
4773 4773 ========= == == == ==
4774 4774 opt/state A C M !
4775 4775 ========= == == == ==
4776 4776 none W RD W R
4777 4777 -f R RD RD R
4778 4778 -A W W W R
4779 4779 -Af R R R R
4780 4780 ========= == == == ==
4781 4781
4782 4782 Note that remove never deletes files in Added [A] state from the
4783 4783 working directory, not even if option --force is specified.
4784 4784
4785 4785 Returns 0 on success, 1 if any warnings encountered.
4786 4786 """
4787 4787
4788 4788 ret = 0
4789 4789 after, force = opts.get('after'), opts.get('force')
4790 4790 if not pats and not after:
4791 4791 raise util.Abort(_('no files specified'))
4792 4792
4793 4793 m = scmutil.match(repo[None], pats, opts)
4794 4794 s = repo.status(match=m, clean=True)
4795 4795 modified, added, deleted, clean = s[0], s[1], s[3], s[6]
4796 4796
4797 4797 # warn about failure to delete explicit files/dirs
4798 4798 wctx = repo[None]
4799 4799 for f in m.files():
4800 4800 if f in repo.dirstate or f in wctx.dirs():
4801 4801 continue
4802 4802 if os.path.exists(m.rel(f)):
4803 4803 if os.path.isdir(m.rel(f)):
4804 4804 ui.warn(_('not removing %s: no tracked files\n') % m.rel(f))
4805 4805 else:
4806 4806 ui.warn(_('not removing %s: file is untracked\n') % m.rel(f))
4807 4807 # missing files will generate a warning elsewhere
4808 4808 ret = 1
4809 4809
4810 4810 if force:
4811 4811 list = modified + deleted + clean + added
4812 4812 elif after:
4813 4813 list = deleted
4814 4814 for f in modified + added + clean:
4815 4815 ui.warn(_('not removing %s: file still exists\n') % m.rel(f))
4816 4816 ret = 1
4817 4817 else:
4818 4818 list = deleted + clean
4819 4819 for f in modified:
4820 4820 ui.warn(_('not removing %s: file is modified (use -f'
4821 4821 ' to force removal)\n') % m.rel(f))
4822 4822 ret = 1
4823 4823 for f in added:
4824 4824 ui.warn(_('not removing %s: file has been marked for add'
4825 4825 ' (use forget to undo)\n') % m.rel(f))
4826 4826 ret = 1
4827 4827
4828 4828 for f in sorted(list):
4829 4829 if ui.verbose or not m.exact(f):
4830 4830 ui.status(_('removing %s\n') % m.rel(f))
4831 4831
4832 4832 wlock = repo.wlock()
4833 4833 try:
4834 4834 if not after:
4835 4835 for f in list:
4836 4836 if f in added:
4837 4837 continue # we never unlink added files on remove
4838 4838 util.unlinkpath(repo.wjoin(f), ignoremissing=True)
4839 4839 repo[None].forget(list)
4840 4840 finally:
4841 4841 wlock.release()
4842 4842
4843 4843 return ret
4844 4844
4845 4845 @command('rename|move|mv',
4846 4846 [('A', 'after', None, _('record a rename that has already occurred')),
4847 4847 ('f', 'force', None, _('forcibly copy over an existing managed file')),
4848 4848 ] + walkopts + dryrunopts,
4849 4849 _('[OPTION]... SOURCE... DEST'))
4850 4850 def rename(ui, repo, *pats, **opts):
4851 4851 """rename files; equivalent of copy + remove
4852 4852
4853 4853 Mark dest as copies of sources; mark sources for deletion. If dest
4854 4854 is a directory, copies are put in that directory. If dest is a
4855 4855 file, there can only be one source.
4856 4856
4857 4857 By default, this command copies the contents of files as they
4858 4858 exist in the working directory. If invoked with -A/--after, the
4859 4859 operation is recorded, but no copying is performed.
4860 4860
4861 4861 This command takes effect at the next commit. To undo a rename
4862 4862 before that, see :hg:`revert`.
4863 4863
4864 4864 Returns 0 on success, 1 if errors are encountered.
4865 4865 """
4866 4866 wlock = repo.wlock(False)
4867 4867 try:
4868 4868 return cmdutil.copy(ui, repo, pats, opts, rename=True)
4869 4869 finally:
4870 4870 wlock.release()
4871 4871
4872 4872 @command('resolve',
4873 4873 [('a', 'all', None, _('select all unresolved files')),
4874 4874 ('l', 'list', None, _('list state of files needing merge')),
4875 4875 ('m', 'mark', None, _('mark files as resolved')),
4876 4876 ('u', 'unmark', None, _('mark files as unresolved')),
4877 4877 ('n', 'no-status', None, _('hide status prefix'))]
4878 4878 + mergetoolopts + walkopts,
4879 4879 _('[OPTION]... [FILE]...'))
4880 4880 def resolve(ui, repo, *pats, **opts):
4881 4881 """redo merges or set/view the merge status of files
4882 4882
4883 4883 Merges with unresolved conflicts are often the result of
4884 4884 non-interactive merging using the ``internal:merge`` configuration
4885 4885 setting, or a command-line merge tool like ``diff3``. The resolve
4886 4886 command is used to manage the files involved in a merge, after
4887 4887 :hg:`merge` has been run, and before :hg:`commit` is run (i.e. the
4888 4888 working directory must have two parents). See :hg:`help
4889 4889 merge-tools` for information on configuring merge tools.
4890 4890
4891 4891 The resolve command can be used in the following ways:
4892 4892
4893 4893 - :hg:`resolve [--tool TOOL] FILE...`: attempt to re-merge the specified
4894 4894 files, discarding any previous merge attempts. Re-merging is not
4895 4895 performed for files already marked as resolved. Use ``--all/-a``
4896 4896 to select all unresolved files. ``--tool`` can be used to specify
4897 4897 the merge tool used for the given files. It overrides the HGMERGE
4898 4898 environment variable and your configuration files. Previous file
4899 4899 contents are saved with a ``.orig`` suffix.
4900 4900
4901 4901 - :hg:`resolve -m [FILE]`: mark a file as having been resolved
4902 4902 (e.g. after having manually fixed-up the files). The default is
4903 4903 to mark all unresolved files.
4904 4904
4905 4905 - :hg:`resolve -u [FILE]...`: mark a file as unresolved. The
4906 4906 default is to mark all resolved files.
4907 4907
4908 4908 - :hg:`resolve -l`: list files which had or still have conflicts.
4909 4909 In the printed list, ``U`` = unresolved and ``R`` = resolved.
4910 4910
4911 4911 Note that Mercurial will not let you commit files with unresolved
4912 4912 merge conflicts. You must use :hg:`resolve -m ...` before you can
4913 4913 commit after a conflicting merge.
4914 4914
4915 4915 Returns 0 on success, 1 if any files fail a resolve attempt.
4916 4916 """
4917 4917
4918 4918 all, mark, unmark, show, nostatus = \
4919 4919 [opts.get(o) for o in 'all mark unmark list no_status'.split()]
4920 4920
4921 4921 if (show and (mark or unmark)) or (mark and unmark):
4922 4922 raise util.Abort(_("too many options specified"))
4923 4923 if pats and all:
4924 4924 raise util.Abort(_("can't specify --all and patterns"))
4925 4925 if not (all or pats or show or mark or unmark):
4926 4926 raise util.Abort(_('no files or directories specified; '
4927 4927 'use --all to remerge all files'))
4928 4928
4929 4929 ms = mergemod.mergestate(repo)
4930 4930
4931 4931 if not ms.active():
4932 4932 raise util.Abort(_('resolve command not applicable when not merging'))
4933 4933
4934 4934 m = scmutil.match(repo[None], pats, opts)
4935 4935 ret = 0
4936 4936
4937 4937 didwork = False
4938 4938 for f in ms:
4939 4939 if not m(f):
4940 4940 continue
4941 4941
4942 4942 didwork = True
4943 4943
4944 4944 if show:
4945 4945 if nostatus:
4946 4946 ui.write("%s\n" % f)
4947 4947 else:
4948 4948 ui.write("%s %s\n" % (ms[f].upper(), f),
4949 4949 label='resolve.' +
4950 4950 {'u': 'unresolved', 'r': 'resolved'}[ms[f]])
4951 4951 elif mark:
4952 4952 ms.mark(f, "r")
4953 4953 elif unmark:
4954 4954 ms.mark(f, "u")
4955 4955 else:
4956 4956 wctx = repo[None]
4957 4957
4958 4958 # backup pre-resolve (merge uses .orig for its own purposes)
4959 4959 a = repo.wjoin(f)
4960 4960 util.copyfile(a, a + ".resolve")
4961 4961
4962 4962 try:
4963 4963 # resolve file
4964 4964 ui.setconfig('ui', 'forcemerge', opts.get('tool', ''),
4965 4965 'resolve')
4966 4966 if ms.resolve(f, wctx):
4967 4967 ret = 1
4968 4968 finally:
4969 4969 ui.setconfig('ui', 'forcemerge', '', 'resolve')
4970 4970 ms.commit()
4971 4971
4972 4972 # replace filemerge's .orig file with our resolve file
4973 4973 util.rename(a + ".resolve", a + ".orig")
4974 4974
4975 4975 ms.commit()
4976 4976
4977 4977 if not didwork and pats:
4978 4978 ui.warn(_("arguments do not match paths that need resolved\n"))
4979 4979
4980 4980 # Nudge users into finishing an unfinished operation. We don't print
4981 4981 # this with the list/show operation because we want list/show to remain
4982 4982 # machine readable.
4983 4983 if not list(ms.unresolved()) and not show:
4984 ui.write(_('no unresolved files; '))
4985 ui.write(_('you may continue your unfinished operation\n'))
4984 ui.status(_('no more unresolved files\n'))
4986 4985
4987 4986 return ret
4988 4987
4989 4988 @command('revert',
4990 4989 [('a', 'all', None, _('revert all changes when no arguments given')),
4991 4990 ('d', 'date', '', _('tipmost revision matching date'), _('DATE')),
4992 4991 ('r', 'rev', '', _('revert to the specified revision'), _('REV')),
4993 4992 ('C', 'no-backup', None, _('do not save backup copies of files')),
4994 4993 ] + walkopts + dryrunopts,
4995 4994 _('[OPTION]... [-r REV] [NAME]...'))
4996 4995 def revert(ui, repo, *pats, **opts):
4997 4996 """restore files to their checkout state
4998 4997
4999 4998 .. note::
5000 4999
5001 5000 To check out earlier revisions, you should use :hg:`update REV`.
5002 5001 To cancel an uncommitted merge (and lose your changes),
5003 5002 use :hg:`update --clean .`.
5004 5003
5005 5004 With no revision specified, revert the specified files or directories
5006 5005 to the contents they had in the parent of the working directory.
5007 5006 This restores the contents of files to an unmodified
5008 5007 state and unschedules adds, removes, copies, and renames. If the
5009 5008 working directory has two parents, you must explicitly specify a
5010 5009 revision.
5011 5010
5012 5011 Using the -r/--rev or -d/--date options, revert the given files or
5013 5012 directories to their states as of a specific revision. Because
5014 5013 revert does not change the working directory parents, this will
5015 5014 cause these files to appear modified. This can be helpful to "back
5016 5015 out" some or all of an earlier change. See :hg:`backout` for a
5017 5016 related method.
5018 5017
5019 5018 Modified files are saved with a .orig suffix before reverting.
5020 5019 To disable these backups, use --no-backup.
5021 5020
5022 5021 See :hg:`help dates` for a list of formats valid for -d/--date.
5023 5022
5024 5023 Returns 0 on success.
5025 5024 """
5026 5025
5027 5026 if opts.get("date"):
5028 5027 if opts.get("rev"):
5029 5028 raise util.Abort(_("you can't specify a revision and a date"))
5030 5029 opts["rev"] = cmdutil.finddate(ui, repo, opts["date"])
5031 5030
5032 5031 parent, p2 = repo.dirstate.parents()
5033 5032 if not opts.get('rev') and p2 != nullid:
5034 5033 # revert after merge is a trap for new users (issue2915)
5035 5034 raise util.Abort(_('uncommitted merge with no revision specified'),
5036 5035 hint=_('use "hg update" or see "hg help revert"'))
5037 5036
5038 5037 ctx = scmutil.revsingle(repo, opts.get('rev'))
5039 5038
5040 5039 if not pats and not opts.get('all'):
5041 5040 msg = _("no files or directories specified")
5042 5041 if p2 != nullid:
5043 5042 hint = _("uncommitted merge, use --all to discard all changes,"
5044 5043 " or 'hg update -C .' to abort the merge")
5045 5044 raise util.Abort(msg, hint=hint)
5046 5045 dirty = util.any(repo.status())
5047 5046 node = ctx.node()
5048 5047 if node != parent:
5049 5048 if dirty:
5050 5049 hint = _("uncommitted changes, use --all to discard all"
5051 5050 " changes, or 'hg update %s' to update") % ctx.rev()
5052 5051 else:
5053 5052 hint = _("use --all to revert all files,"
5054 5053 " or 'hg update %s' to update") % ctx.rev()
5055 5054 elif dirty:
5056 5055 hint = _("uncommitted changes, use --all to discard all changes")
5057 5056 else:
5058 5057 hint = _("use --all to revert all files")
5059 5058 raise util.Abort(msg, hint=hint)
5060 5059
5061 5060 return cmdutil.revert(ui, repo, ctx, (parent, p2), *pats, **opts)
5062 5061
5063 5062 @command('rollback', dryrunopts +
5064 5063 [('f', 'force', False, _('ignore safety measures'))])
5065 5064 def rollback(ui, repo, **opts):
5066 5065 """roll back the last transaction (DANGEROUS) (DEPRECATED)
5067 5066
5068 5067 Please use :hg:`commit --amend` instead of rollback to correct
5069 5068 mistakes in the last commit.
5070 5069
5071 5070 This command should be used with care. There is only one level of
5072 5071 rollback, and there is no way to undo a rollback. It will also
5073 5072 restore the dirstate at the time of the last transaction, losing
5074 5073 any dirstate changes since that time. This command does not alter
5075 5074 the working directory.
5076 5075
5077 5076 Transactions are used to encapsulate the effects of all commands
5078 5077 that create new changesets or propagate existing changesets into a
5079 5078 repository.
5080 5079
5081 5080 .. container:: verbose
5082 5081
5083 5082 For example, the following commands are transactional, and their
5084 5083 effects can be rolled back:
5085 5084
5086 5085 - commit
5087 5086 - import
5088 5087 - pull
5089 5088 - push (with this repository as the destination)
5090 5089 - unbundle
5091 5090
5092 5091 To avoid permanent data loss, rollback will refuse to rollback a
5093 5092 commit transaction if it isn't checked out. Use --force to
5094 5093 override this protection.
5095 5094
5096 5095 This command is not intended for use on public repositories. Once
5097 5096 changes are visible for pull by other users, rolling a transaction
5098 5097 back locally is ineffective (someone else may already have pulled
5099 5098 the changes). Furthermore, a race is possible with readers of the
5100 5099 repository; for example an in-progress pull from the repository
5101 5100 may fail if a rollback is performed.
5102 5101
5103 5102 Returns 0 on success, 1 if no rollback data is available.
5104 5103 """
5105 5104 return repo.rollback(dryrun=opts.get('dry_run'),
5106 5105 force=opts.get('force'))
5107 5106
5108 5107 @command('root', [])
5109 5108 def root(ui, repo):
5110 5109 """print the root (top) of the current working directory
5111 5110
5112 5111 Print the root directory of the current repository.
5113 5112
5114 5113 Returns 0 on success.
5115 5114 """
5116 5115 ui.write(repo.root + "\n")
5117 5116
5118 5117 @command('^serve',
5119 5118 [('A', 'accesslog', '', _('name of access log file to write to'),
5120 5119 _('FILE')),
5121 5120 ('d', 'daemon', None, _('run server in background')),
5122 5121 ('', 'daemon-pipefds', '', _('used internally by daemon mode'), _('NUM')),
5123 5122 ('E', 'errorlog', '', _('name of error log file to write to'), _('FILE')),
5124 5123 # use string type, then we can check if something was passed
5125 5124 ('p', 'port', '', _('port to listen on (default: 8000)'), _('PORT')),
5126 5125 ('a', 'address', '', _('address to listen on (default: all interfaces)'),
5127 5126 _('ADDR')),
5128 5127 ('', 'prefix', '', _('prefix path to serve from (default: server root)'),
5129 5128 _('PREFIX')),
5130 5129 ('n', 'name', '',
5131 5130 _('name to show in web pages (default: working directory)'), _('NAME')),
5132 5131 ('', 'web-conf', '',
5133 5132 _('name of the hgweb config file (see "hg help hgweb")'), _('FILE')),
5134 5133 ('', 'webdir-conf', '', _('name of the hgweb config file (DEPRECATED)'),
5135 5134 _('FILE')),
5136 5135 ('', 'pid-file', '', _('name of file to write process ID to'), _('FILE')),
5137 5136 ('', 'stdio', None, _('for remote clients')),
5138 5137 ('', 'cmdserver', '', _('for remote clients'), _('MODE')),
5139 5138 ('t', 'templates', '', _('web templates to use'), _('TEMPLATE')),
5140 5139 ('', 'style', '', _('template style to use'), _('STYLE')),
5141 5140 ('6', 'ipv6', None, _('use IPv6 in addition to IPv4')),
5142 5141 ('', 'certificate', '', _('SSL certificate file'), _('FILE'))],
5143 5142 _('[OPTION]...'))
5144 5143 def serve(ui, repo, **opts):
5145 5144 """start stand-alone webserver
5146 5145
5147 5146 Start a local HTTP repository browser and pull server. You can use
5148 5147 this for ad-hoc sharing and browsing of repositories. It is
5149 5148 recommended to use a real web server to serve a repository for
5150 5149 longer periods of time.
5151 5150
5152 5151 Please note that the server does not implement access control.
5153 5152 This means that, by default, anybody can read from the server and
5154 5153 nobody can write to it by default. Set the ``web.allow_push``
5155 5154 option to ``*`` to allow everybody to push to the server. You
5156 5155 should use a real web server if you need to authenticate users.
5157 5156
5158 5157 By default, the server logs accesses to stdout and errors to
5159 5158 stderr. Use the -A/--accesslog and -E/--errorlog options to log to
5160 5159 files.
5161 5160
5162 5161 To have the server choose a free port number to listen on, specify
5163 5162 a port number of 0; in this case, the server will print the port
5164 5163 number it uses.
5165 5164
5166 5165 Returns 0 on success.
5167 5166 """
5168 5167
5169 5168 if opts["stdio"] and opts["cmdserver"]:
5170 5169 raise util.Abort(_("cannot use --stdio with --cmdserver"))
5171 5170
5172 5171 def checkrepo():
5173 5172 if repo is None:
5174 5173 raise error.RepoError(_("there is no Mercurial repository here"
5175 5174 " (.hg not found)"))
5176 5175
5177 5176 if opts["stdio"]:
5178 5177 checkrepo()
5179 5178 s = sshserver.sshserver(ui, repo)
5180 5179 s.serve_forever()
5181 5180
5182 5181 if opts["cmdserver"]:
5183 5182 s = commandserver.server(ui, repo, opts["cmdserver"])
5184 5183 return s.serve()
5185 5184
5186 5185 # this way we can check if something was given in the command-line
5187 5186 if opts.get('port'):
5188 5187 opts['port'] = util.getport(opts.get('port'))
5189 5188
5190 5189 baseui = repo and repo.baseui or ui
5191 5190 optlist = ("name templates style address port prefix ipv6"
5192 5191 " accesslog errorlog certificate encoding")
5193 5192 for o in optlist.split():
5194 5193 val = opts.get(o, '')
5195 5194 if val in (None, ''): # should check against default options instead
5196 5195 continue
5197 5196 baseui.setconfig("web", o, val, 'serve')
5198 5197 if repo and repo.ui != baseui:
5199 5198 repo.ui.setconfig("web", o, val, 'serve')
5200 5199
5201 5200 o = opts.get('web_conf') or opts.get('webdir_conf')
5202 5201 if not o:
5203 5202 if not repo:
5204 5203 raise error.RepoError(_("there is no Mercurial repository"
5205 5204 " here (.hg not found)"))
5206 5205 o = repo
5207 5206
5208 5207 app = hgweb.hgweb(o, baseui=baseui)
5209 5208 service = httpservice(ui, app, opts)
5210 5209 cmdutil.service(opts, initfn=service.init, runfn=service.run)
5211 5210
5212 5211 class httpservice(object):
5213 5212 def __init__(self, ui, app, opts):
5214 5213 self.ui = ui
5215 5214 self.app = app
5216 5215 self.opts = opts
5217 5216
5218 5217 def init(self):
5219 5218 util.setsignalhandler()
5220 5219 self.httpd = hgweb_server.create_server(self.ui, self.app)
5221 5220
5222 5221 if self.opts['port'] and not self.ui.verbose:
5223 5222 return
5224 5223
5225 5224 if self.httpd.prefix:
5226 5225 prefix = self.httpd.prefix.strip('/') + '/'
5227 5226 else:
5228 5227 prefix = ''
5229 5228
5230 5229 port = ':%d' % self.httpd.port
5231 5230 if port == ':80':
5232 5231 port = ''
5233 5232
5234 5233 bindaddr = self.httpd.addr
5235 5234 if bindaddr == '0.0.0.0':
5236 5235 bindaddr = '*'
5237 5236 elif ':' in bindaddr: # IPv6
5238 5237 bindaddr = '[%s]' % bindaddr
5239 5238
5240 5239 fqaddr = self.httpd.fqaddr
5241 5240 if ':' in fqaddr:
5242 5241 fqaddr = '[%s]' % fqaddr
5243 5242 if self.opts['port']:
5244 5243 write = self.ui.status
5245 5244 else:
5246 5245 write = self.ui.write
5247 5246 write(_('listening at http://%s%s/%s (bound to %s:%d)\n') %
5248 5247 (fqaddr, port, prefix, bindaddr, self.httpd.port))
5249 5248
5250 5249 def run(self):
5251 5250 self.httpd.serve_forever()
5252 5251
5253 5252
5254 5253 @command('^status|st',
5255 5254 [('A', 'all', None, _('show status of all files')),
5256 5255 ('m', 'modified', None, _('show only modified files')),
5257 5256 ('a', 'added', None, _('show only added files')),
5258 5257 ('r', 'removed', None, _('show only removed files')),
5259 5258 ('d', 'deleted', None, _('show only deleted (but tracked) files')),
5260 5259 ('c', 'clean', None, _('show only files without changes')),
5261 5260 ('u', 'unknown', None, _('show only unknown (not tracked) files')),
5262 5261 ('i', 'ignored', None, _('show only ignored files')),
5263 5262 ('n', 'no-status', None, _('hide status prefix')),
5264 5263 ('C', 'copies', None, _('show source of copied files')),
5265 5264 ('0', 'print0', None, _('end filenames with NUL, for use with xargs')),
5266 5265 ('', 'rev', [], _('show difference from revision'), _('REV')),
5267 5266 ('', 'change', '', _('list the changed files of a revision'), _('REV')),
5268 5267 ] + walkopts + subrepoopts,
5269 5268 _('[OPTION]... [FILE]...'))
5270 5269 def status(ui, repo, *pats, **opts):
5271 5270 """show changed files in the working directory
5272 5271
5273 5272 Show status of files in the repository. If names are given, only
5274 5273 files that match are shown. Files that are clean or ignored or
5275 5274 the source of a copy/move operation, are not listed unless
5276 5275 -c/--clean, -i/--ignored, -C/--copies or -A/--all are given.
5277 5276 Unless options described with "show only ..." are given, the
5278 5277 options -mardu are used.
5279 5278
5280 5279 Option -q/--quiet hides untracked (unknown and ignored) files
5281 5280 unless explicitly requested with -u/--unknown or -i/--ignored.
5282 5281
5283 5282 .. note::
5284 5283
5285 5284 status may appear to disagree with diff if permissions have
5286 5285 changed or a merge has occurred. The standard diff format does
5287 5286 not report permission changes and diff only reports changes
5288 5287 relative to one merge parent.
5289 5288
5290 5289 If one revision is given, it is used as the base revision.
5291 5290 If two revisions are given, the differences between them are
5292 5291 shown. The --change option can also be used as a shortcut to list
5293 5292 the changed files of a revision from its first parent.
5294 5293
5295 5294 The codes used to show the status of files are::
5296 5295
5297 5296 M = modified
5298 5297 A = added
5299 5298 R = removed
5300 5299 C = clean
5301 5300 ! = missing (deleted by non-hg command, but still tracked)
5302 5301 ? = not tracked
5303 5302 I = ignored
5304 5303 = origin of the previous file (with --copies)
5305 5304
5306 5305 .. container:: verbose
5307 5306
5308 5307 Examples:
5309 5308
5310 5309 - show changes in the working directory relative to a
5311 5310 changeset::
5312 5311
5313 5312 hg status --rev 9353
5314 5313
5315 5314 - show all changes including copies in an existing changeset::
5316 5315
5317 5316 hg status --copies --change 9353
5318 5317
5319 5318 - get a NUL separated list of added files, suitable for xargs::
5320 5319
5321 5320 hg status -an0
5322 5321
5323 5322 Returns 0 on success.
5324 5323 """
5325 5324
5326 5325 revs = opts.get('rev')
5327 5326 change = opts.get('change')
5328 5327
5329 5328 if revs and change:
5330 5329 msg = _('cannot specify --rev and --change at the same time')
5331 5330 raise util.Abort(msg)
5332 5331 elif change:
5333 5332 node2 = scmutil.revsingle(repo, change, None).node()
5334 5333 node1 = repo[node2].p1().node()
5335 5334 else:
5336 5335 node1, node2 = scmutil.revpair(repo, revs)
5337 5336
5338 5337 cwd = (pats and repo.getcwd()) or ''
5339 5338 end = opts.get('print0') and '\0' or '\n'
5340 5339 copy = {}
5341 5340 states = 'modified added removed deleted unknown ignored clean'.split()
5342 5341 show = [k for k in states if opts.get(k)]
5343 5342 if opts.get('all'):
5344 5343 show += ui.quiet and (states[:4] + ['clean']) or states
5345 5344 if not show:
5346 5345 show = ui.quiet and states[:4] or states[:5]
5347 5346
5348 5347 stat = repo.status(node1, node2, scmutil.match(repo[node2], pats, opts),
5349 5348 'ignored' in show, 'clean' in show, 'unknown' in show,
5350 5349 opts.get('subrepos'))
5351 5350 changestates = zip(states, 'MAR!?IC', stat)
5352 5351
5353 5352 if (opts.get('all') or opts.get('copies')) and not opts.get('no_status'):
5354 5353 copy = copies.pathcopies(repo[node1], repo[node2])
5355 5354
5356 5355 fm = ui.formatter('status', opts)
5357 5356 fmt = '%s' + end
5358 5357 showchar = not opts.get('no_status')
5359 5358
5360 5359 for state, char, files in changestates:
5361 5360 if state in show:
5362 5361 label = 'status.' + state
5363 5362 for f in files:
5364 5363 fm.startitem()
5365 5364 fm.condwrite(showchar, 'status', '%s ', char, label=label)
5366 5365 fm.write('path', fmt, repo.pathto(f, cwd), label=label)
5367 5366 if f in copy:
5368 5367 fm.write("copy", ' %s' + end, repo.pathto(copy[f], cwd),
5369 5368 label='status.copied')
5370 5369 fm.end()
5371 5370
5372 5371 @command('^summary|sum',
5373 5372 [('', 'remote', None, _('check for push and pull'))], '[--remote]')
5374 5373 def summary(ui, repo, **opts):
5375 5374 """summarize working directory state
5376 5375
5377 5376 This generates a brief summary of the working directory state,
5378 5377 including parents, branch, commit status, and available updates.
5379 5378
5380 5379 With the --remote option, this will check the default paths for
5381 5380 incoming and outgoing changes. This can be time-consuming.
5382 5381
5383 5382 Returns 0 on success.
5384 5383 """
5385 5384
5386 5385 ctx = repo[None]
5387 5386 parents = ctx.parents()
5388 5387 pnode = parents[0].node()
5389 5388 marks = []
5390 5389
5391 5390 for p in parents:
5392 5391 # label with log.changeset (instead of log.parent) since this
5393 5392 # shows a working directory parent *changeset*:
5394 5393 # i18n: column positioning for "hg summary"
5395 5394 ui.write(_('parent: %d:%s ') % (p.rev(), str(p)),
5396 5395 label='log.changeset changeset.%s' % p.phasestr())
5397 5396 ui.write(' '.join(p.tags()), label='log.tag')
5398 5397 if p.bookmarks():
5399 5398 marks.extend(p.bookmarks())
5400 5399 if p.rev() == -1:
5401 5400 if not len(repo):
5402 5401 ui.write(_(' (empty repository)'))
5403 5402 else:
5404 5403 ui.write(_(' (no revision checked out)'))
5405 5404 ui.write('\n')
5406 5405 if p.description():
5407 5406 ui.status(' ' + p.description().splitlines()[0].strip() + '\n',
5408 5407 label='log.summary')
5409 5408
5410 5409 branch = ctx.branch()
5411 5410 bheads = repo.branchheads(branch)
5412 5411 # i18n: column positioning for "hg summary"
5413 5412 m = _('branch: %s\n') % branch
5414 5413 if branch != 'default':
5415 5414 ui.write(m, label='log.branch')
5416 5415 else:
5417 5416 ui.status(m, label='log.branch')
5418 5417
5419 5418 if marks:
5420 5419 current = repo._bookmarkcurrent
5421 5420 # i18n: column positioning for "hg summary"
5422 5421 ui.write(_('bookmarks:'), label='log.bookmark')
5423 5422 if current is not None:
5424 5423 if current in marks:
5425 5424 ui.write(' *' + current, label='bookmarks.current')
5426 5425 marks.remove(current)
5427 5426 else:
5428 5427 ui.write(' [%s]' % current, label='bookmarks.current')
5429 5428 for m in marks:
5430 5429 ui.write(' ' + m, label='log.bookmark')
5431 5430 ui.write('\n', label='log.bookmark')
5432 5431
5433 5432 st = list(repo.status(unknown=True))[:6]
5434 5433
5435 5434 c = repo.dirstate.copies()
5436 5435 copied, renamed = [], []
5437 5436 for d, s in c.iteritems():
5438 5437 if s in st[2]:
5439 5438 st[2].remove(s)
5440 5439 renamed.append(d)
5441 5440 else:
5442 5441 copied.append(d)
5443 5442 if d in st[1]:
5444 5443 st[1].remove(d)
5445 5444 st.insert(3, renamed)
5446 5445 st.insert(4, copied)
5447 5446
5448 5447 ms = mergemod.mergestate(repo)
5449 5448 st.append([f for f in ms if ms[f] == 'u'])
5450 5449
5451 5450 subs = [s for s in ctx.substate if ctx.sub(s).dirty()]
5452 5451 st.append(subs)
5453 5452
5454 5453 labels = [ui.label(_('%d modified'), 'status.modified'),
5455 5454 ui.label(_('%d added'), 'status.added'),
5456 5455 ui.label(_('%d removed'), 'status.removed'),
5457 5456 ui.label(_('%d renamed'), 'status.copied'),
5458 5457 ui.label(_('%d copied'), 'status.copied'),
5459 5458 ui.label(_('%d deleted'), 'status.deleted'),
5460 5459 ui.label(_('%d unknown'), 'status.unknown'),
5461 5460 ui.label(_('%d ignored'), 'status.ignored'),
5462 5461 ui.label(_('%d unresolved'), 'resolve.unresolved'),
5463 5462 ui.label(_('%d subrepos'), 'status.modified')]
5464 5463 t = []
5465 5464 for s, l in zip(st, labels):
5466 5465 if s:
5467 5466 t.append(l % len(s))
5468 5467
5469 5468 t = ', '.join(t)
5470 5469 cleanworkdir = False
5471 5470
5472 5471 if repo.vfs.exists('updatestate'):
5473 5472 t += _(' (interrupted update)')
5474 5473 elif len(parents) > 1:
5475 5474 t += _(' (merge)')
5476 5475 elif branch != parents[0].branch():
5477 5476 t += _(' (new branch)')
5478 5477 elif (parents[0].closesbranch() and
5479 5478 pnode in repo.branchheads(branch, closed=True)):
5480 5479 t += _(' (head closed)')
5481 5480 elif not (st[0] or st[1] or st[2] or st[3] or st[4] or st[9]):
5482 5481 t += _(' (clean)')
5483 5482 cleanworkdir = True
5484 5483 elif pnode not in bheads:
5485 5484 t += _(' (new branch head)')
5486 5485
5487 5486 if cleanworkdir:
5488 5487 # i18n: column positioning for "hg summary"
5489 5488 ui.status(_('commit: %s\n') % t.strip())
5490 5489 else:
5491 5490 # i18n: column positioning for "hg summary"
5492 5491 ui.write(_('commit: %s\n') % t.strip())
5493 5492
5494 5493 # all ancestors of branch heads - all ancestors of parent = new csets
5495 5494 new = len(repo.changelog.findmissing([ctx.node() for ctx in parents],
5496 5495 bheads))
5497 5496
5498 5497 if new == 0:
5499 5498 # i18n: column positioning for "hg summary"
5500 5499 ui.status(_('update: (current)\n'))
5501 5500 elif pnode not in bheads:
5502 5501 # i18n: column positioning for "hg summary"
5503 5502 ui.write(_('update: %d new changesets (update)\n') % new)
5504 5503 else:
5505 5504 # i18n: column positioning for "hg summary"
5506 5505 ui.write(_('update: %d new changesets, %d branch heads (merge)\n') %
5507 5506 (new, len(bheads)))
5508 5507
5509 5508 cmdutil.summaryhooks(ui, repo)
5510 5509
5511 5510 if opts.get('remote'):
5512 5511 needsincoming, needsoutgoing = True, True
5513 5512 else:
5514 5513 needsincoming, needsoutgoing = False, False
5515 5514 for i, o in cmdutil.summaryremotehooks(ui, repo, opts, None):
5516 5515 if i:
5517 5516 needsincoming = True
5518 5517 if o:
5519 5518 needsoutgoing = True
5520 5519 if not needsincoming and not needsoutgoing:
5521 5520 return
5522 5521
5523 5522 def getincoming():
5524 5523 source, branches = hg.parseurl(ui.expandpath('default'))
5525 5524 sbranch = branches[0]
5526 5525 try:
5527 5526 other = hg.peer(repo, {}, source)
5528 5527 except error.RepoError:
5529 5528 if opts.get('remote'):
5530 5529 raise
5531 5530 return source, sbranch, None, None, None
5532 5531 revs, checkout = hg.addbranchrevs(repo, other, branches, None)
5533 5532 if revs:
5534 5533 revs = [other.lookup(rev) for rev in revs]
5535 5534 ui.debug('comparing with %s\n' % util.hidepassword(source))
5536 5535 repo.ui.pushbuffer()
5537 5536 commoninc = discovery.findcommonincoming(repo, other, heads=revs)
5538 5537 repo.ui.popbuffer()
5539 5538 return source, sbranch, other, commoninc, commoninc[1]
5540 5539
5541 5540 if needsincoming:
5542 5541 source, sbranch, sother, commoninc, incoming = getincoming()
5543 5542 else:
5544 5543 source = sbranch = sother = commoninc = incoming = None
5545 5544
5546 5545 def getoutgoing():
5547 5546 dest, branches = hg.parseurl(ui.expandpath('default-push', 'default'))
5548 5547 dbranch = branches[0]
5549 5548 revs, checkout = hg.addbranchrevs(repo, repo, branches, None)
5550 5549 if source != dest:
5551 5550 try:
5552 5551 dother = hg.peer(repo, {}, dest)
5553 5552 except error.RepoError:
5554 5553 if opts.get('remote'):
5555 5554 raise
5556 5555 return dest, dbranch, None, None
5557 5556 ui.debug('comparing with %s\n' % util.hidepassword(dest))
5558 5557 elif sother is None:
5559 5558 # there is no explicit destination peer, but source one is invalid
5560 5559 return dest, dbranch, None, None
5561 5560 else:
5562 5561 dother = sother
5563 5562 if (source != dest or (sbranch is not None and sbranch != dbranch)):
5564 5563 common = None
5565 5564 else:
5566 5565 common = commoninc
5567 5566 if revs:
5568 5567 revs = [repo.lookup(rev) for rev in revs]
5569 5568 repo.ui.pushbuffer()
5570 5569 outgoing = discovery.findcommonoutgoing(repo, dother, onlyheads=revs,
5571 5570 commoninc=common)
5572 5571 repo.ui.popbuffer()
5573 5572 return dest, dbranch, dother, outgoing
5574 5573
5575 5574 if needsoutgoing:
5576 5575 dest, dbranch, dother, outgoing = getoutgoing()
5577 5576 else:
5578 5577 dest = dbranch = dother = outgoing = None
5579 5578
5580 5579 if opts.get('remote'):
5581 5580 t = []
5582 5581 if incoming:
5583 5582 t.append(_('1 or more incoming'))
5584 5583 o = outgoing.missing
5585 5584 if o:
5586 5585 t.append(_('%d outgoing') % len(o))
5587 5586 other = dother or sother
5588 5587 if 'bookmarks' in other.listkeys('namespaces'):
5589 5588 lmarks = repo.listkeys('bookmarks')
5590 5589 rmarks = other.listkeys('bookmarks')
5591 5590 diff = set(rmarks) - set(lmarks)
5592 5591 if len(diff) > 0:
5593 5592 t.append(_('%d incoming bookmarks') % len(diff))
5594 5593 diff = set(lmarks) - set(rmarks)
5595 5594 if len(diff) > 0:
5596 5595 t.append(_('%d outgoing bookmarks') % len(diff))
5597 5596
5598 5597 if t:
5599 5598 # i18n: column positioning for "hg summary"
5600 5599 ui.write(_('remote: %s\n') % (', '.join(t)))
5601 5600 else:
5602 5601 # i18n: column positioning for "hg summary"
5603 5602 ui.status(_('remote: (synced)\n'))
5604 5603
5605 5604 cmdutil.summaryremotehooks(ui, repo, opts,
5606 5605 ((source, sbranch, sother, commoninc),
5607 5606 (dest, dbranch, dother, outgoing)))
5608 5607
5609 5608 @command('tag',
5610 5609 [('f', 'force', None, _('force tag')),
5611 5610 ('l', 'local', None, _('make the tag local')),
5612 5611 ('r', 'rev', '', _('revision to tag'), _('REV')),
5613 5612 ('', 'remove', None, _('remove a tag')),
5614 5613 # -l/--local is already there, commitopts cannot be used
5615 5614 ('e', 'edit', None, _('edit commit message')),
5616 5615 ('m', 'message', '', _('use <text> as commit message'), _('TEXT')),
5617 5616 ] + commitopts2,
5618 5617 _('[-f] [-l] [-m TEXT] [-d DATE] [-u USER] [-r REV] NAME...'))
5619 5618 def tag(ui, repo, name1, *names, **opts):
5620 5619 """add one or more tags for the current or given revision
5621 5620
5622 5621 Name a particular revision using <name>.
5623 5622
5624 5623 Tags are used to name particular revisions of the repository and are
5625 5624 very useful to compare different revisions, to go back to significant
5626 5625 earlier versions or to mark branch points as releases, etc. Changing
5627 5626 an existing tag is normally disallowed; use -f/--force to override.
5628 5627
5629 5628 If no revision is given, the parent of the working directory is
5630 5629 used.
5631 5630
5632 5631 To facilitate version control, distribution, and merging of tags,
5633 5632 they are stored as a file named ".hgtags" which is managed similarly
5634 5633 to other project files and can be hand-edited if necessary. This
5635 5634 also means that tagging creates a new commit. The file
5636 5635 ".hg/localtags" is used for local tags (not shared among
5637 5636 repositories).
5638 5637
5639 5638 Tag commits are usually made at the head of a branch. If the parent
5640 5639 of the working directory is not a branch head, :hg:`tag` aborts; use
5641 5640 -f/--force to force the tag commit to be based on a non-head
5642 5641 changeset.
5643 5642
5644 5643 See :hg:`help dates` for a list of formats valid for -d/--date.
5645 5644
5646 5645 Since tag names have priority over branch names during revision
5647 5646 lookup, using an existing branch name as a tag name is discouraged.
5648 5647
5649 5648 Returns 0 on success.
5650 5649 """
5651 5650 wlock = lock = None
5652 5651 try:
5653 5652 wlock = repo.wlock()
5654 5653 lock = repo.lock()
5655 5654 rev_ = "."
5656 5655 names = [t.strip() for t in (name1,) + names]
5657 5656 if len(names) != len(set(names)):
5658 5657 raise util.Abort(_('tag names must be unique'))
5659 5658 for n in names:
5660 5659 scmutil.checknewlabel(repo, n, 'tag')
5661 5660 if not n:
5662 5661 raise util.Abort(_('tag names cannot consist entirely of '
5663 5662 'whitespace'))
5664 5663 if opts.get('rev') and opts.get('remove'):
5665 5664 raise util.Abort(_("--rev and --remove are incompatible"))
5666 5665 if opts.get('rev'):
5667 5666 rev_ = opts['rev']
5668 5667 message = opts.get('message')
5669 5668 if opts.get('remove'):
5670 5669 expectedtype = opts.get('local') and 'local' or 'global'
5671 5670 for n in names:
5672 5671 if not repo.tagtype(n):
5673 5672 raise util.Abort(_("tag '%s' does not exist") % n)
5674 5673 if repo.tagtype(n) != expectedtype:
5675 5674 if expectedtype == 'global':
5676 5675 raise util.Abort(_("tag '%s' is not a global tag") % n)
5677 5676 else:
5678 5677 raise util.Abort(_("tag '%s' is not a local tag") % n)
5679 5678 rev_ = nullid
5680 5679 if not message:
5681 5680 # we don't translate commit messages
5682 5681 message = 'Removed tag %s' % ', '.join(names)
5683 5682 elif not opts.get('force'):
5684 5683 for n in names:
5685 5684 if n in repo.tags():
5686 5685 raise util.Abort(_("tag '%s' already exists "
5687 5686 "(use -f to force)") % n)
5688 5687 if not opts.get('local'):
5689 5688 p1, p2 = repo.dirstate.parents()
5690 5689 if p2 != nullid:
5691 5690 raise util.Abort(_('uncommitted merge'))
5692 5691 bheads = repo.branchheads()
5693 5692 if not opts.get('force') and bheads and p1 not in bheads:
5694 5693 raise util.Abort(_('not at a branch head (use -f to force)'))
5695 5694 r = scmutil.revsingle(repo, rev_).node()
5696 5695
5697 5696 if not message:
5698 5697 # we don't translate commit messages
5699 5698 message = ('Added tag %s for changeset %s' %
5700 5699 (', '.join(names), short(r)))
5701 5700
5702 5701 date = opts.get('date')
5703 5702 if date:
5704 5703 date = util.parsedate(date)
5705 5704
5706 5705 if opts.get('edit'):
5707 5706 def editor(repo, ctx, subs):
5708 5707 return ui.edit(ctx.description() + "\n", ctx.user())
5709 5708 else:
5710 5709 editor = False
5711 5710
5712 5711 # don't allow tagging the null rev
5713 5712 if (not opts.get('remove') and
5714 5713 scmutil.revsingle(repo, rev_).rev() == nullrev):
5715 5714 raise util.Abort(_("cannot tag null revision"))
5716 5715
5717 5716 repo.tag(names, r, message, opts.get('local'), opts.get('user'), date,
5718 5717 editor=editor)
5719 5718 finally:
5720 5719 release(lock, wlock)
5721 5720
5722 5721 @command('tags', [], '')
5723 5722 def tags(ui, repo, **opts):
5724 5723 """list repository tags
5725 5724
5726 5725 This lists both regular and local tags. When the -v/--verbose
5727 5726 switch is used, a third column "local" is printed for local tags.
5728 5727
5729 5728 Returns 0 on success.
5730 5729 """
5731 5730
5732 5731 fm = ui.formatter('tags', opts)
5733 5732 hexfunc = ui.debugflag and hex or short
5734 5733 tagtype = ""
5735 5734
5736 5735 for t, n in reversed(repo.tagslist()):
5737 5736 hn = hexfunc(n)
5738 5737 label = 'tags.normal'
5739 5738 tagtype = ''
5740 5739 if repo.tagtype(t) == 'local':
5741 5740 label = 'tags.local'
5742 5741 tagtype = 'local'
5743 5742
5744 5743 fm.startitem()
5745 5744 fm.write('tag', '%s', t, label=label)
5746 5745 fmt = " " * (30 - encoding.colwidth(t)) + ' %5d:%s'
5747 5746 fm.condwrite(not ui.quiet, 'rev id', fmt,
5748 5747 repo.changelog.rev(n), hn, label=label)
5749 5748 fm.condwrite(ui.verbose and tagtype, 'type', ' %s',
5750 5749 tagtype, label=label)
5751 5750 fm.plain('\n')
5752 5751 fm.end()
5753 5752
5754 5753 @command('tip',
5755 5754 [('p', 'patch', None, _('show patch')),
5756 5755 ('g', 'git', None, _('use git extended diff format')),
5757 5756 ] + templateopts,
5758 5757 _('[-p] [-g]'))
5759 5758 def tip(ui, repo, **opts):
5760 5759 """show the tip revision (DEPRECATED)
5761 5760
5762 5761 The tip revision (usually just called the tip) is the changeset
5763 5762 most recently added to the repository (and therefore the most
5764 5763 recently changed head).
5765 5764
5766 5765 If you have just made a commit, that commit will be the tip. If
5767 5766 you have just pulled changes from another repository, the tip of
5768 5767 that repository becomes the current tip. The "tip" tag is special
5769 5768 and cannot be renamed or assigned to a different changeset.
5770 5769
5771 5770 This command is deprecated, please use :hg:`heads` instead.
5772 5771
5773 5772 Returns 0 on success.
5774 5773 """
5775 5774 displayer = cmdutil.show_changeset(ui, repo, opts)
5776 5775 displayer.show(repo['tip'])
5777 5776 displayer.close()
5778 5777
5779 5778 @command('unbundle',
5780 5779 [('u', 'update', None,
5781 5780 _('update to new branch head if changesets were unbundled'))],
5782 5781 _('[-u] FILE...'))
5783 5782 def unbundle(ui, repo, fname1, *fnames, **opts):
5784 5783 """apply one or more changegroup files
5785 5784
5786 5785 Apply one or more compressed changegroup files generated by the
5787 5786 bundle command.
5788 5787
5789 5788 Returns 0 on success, 1 if an update has unresolved files.
5790 5789 """
5791 5790 fnames = (fname1,) + fnames
5792 5791
5793 5792 lock = repo.lock()
5794 5793 wc = repo['.']
5795 5794 try:
5796 5795 for fname in fnames:
5797 5796 f = hg.openpath(ui, fname)
5798 5797 gen = exchange.readbundle(ui, f, fname)
5799 5798 modheads = changegroup.addchangegroup(repo, gen, 'unbundle',
5800 5799 'bundle:' + fname)
5801 5800 finally:
5802 5801 lock.release()
5803 5802 bookmarks.updatecurrentbookmark(repo, wc.node(), wc.branch())
5804 5803 return postincoming(ui, repo, modheads, opts.get('update'), None)
5805 5804
5806 5805 @command('^update|up|checkout|co',
5807 5806 [('C', 'clean', None, _('discard uncommitted changes (no backup)')),
5808 5807 ('c', 'check', None,
5809 5808 _('update across branches if no uncommitted changes')),
5810 5809 ('d', 'date', '', _('tipmost revision matching date'), _('DATE')),
5811 5810 ('r', 'rev', '', _('revision'), _('REV'))],
5812 5811 _('[-c] [-C] [-d DATE] [[-r] REV]'))
5813 5812 def update(ui, repo, node=None, rev=None, clean=False, date=None, check=False):
5814 5813 """update working directory (or switch revisions)
5815 5814
5816 5815 Update the repository's working directory to the specified
5817 5816 changeset. If no changeset is specified, update to the tip of the
5818 5817 current named branch and move the current bookmark (see :hg:`help
5819 5818 bookmarks`).
5820 5819
5821 5820 Update sets the working directory's parent revision to the specified
5822 5821 changeset (see :hg:`help parents`).
5823 5822
5824 5823 If the changeset is not a descendant or ancestor of the working
5825 5824 directory's parent, the update is aborted. With the -c/--check
5826 5825 option, the working directory is checked for uncommitted changes; if
5827 5826 none are found, the working directory is updated to the specified
5828 5827 changeset.
5829 5828
5830 5829 .. container:: verbose
5831 5830
5832 5831 The following rules apply when the working directory contains
5833 5832 uncommitted changes:
5834 5833
5835 5834 1. If neither -c/--check nor -C/--clean is specified, and if
5836 5835 the requested changeset is an ancestor or descendant of
5837 5836 the working directory's parent, the uncommitted changes
5838 5837 are merged into the requested changeset and the merged
5839 5838 result is left uncommitted. If the requested changeset is
5840 5839 not an ancestor or descendant (that is, it is on another
5841 5840 branch), the update is aborted and the uncommitted changes
5842 5841 are preserved.
5843 5842
5844 5843 2. With the -c/--check option, the update is aborted and the
5845 5844 uncommitted changes are preserved.
5846 5845
5847 5846 3. With the -C/--clean option, uncommitted changes are discarded and
5848 5847 the working directory is updated to the requested changeset.
5849 5848
5850 5849 To cancel an uncommitted merge (and lose your changes), use
5851 5850 :hg:`update --clean .`.
5852 5851
5853 5852 Use null as the changeset to remove the working directory (like
5854 5853 :hg:`clone -U`).
5855 5854
5856 5855 If you want to revert just one file to an older revision, use
5857 5856 :hg:`revert [-r REV] NAME`.
5858 5857
5859 5858 See :hg:`help dates` for a list of formats valid for -d/--date.
5860 5859
5861 5860 Returns 0 on success, 1 if there are unresolved files.
5862 5861 """
5863 5862 if rev and node:
5864 5863 raise util.Abort(_("please specify just one revision"))
5865 5864
5866 5865 if rev is None or rev == '':
5867 5866 rev = node
5868 5867
5869 5868 cmdutil.clearunfinished(repo)
5870 5869
5871 5870 # with no argument, we also move the current bookmark, if any
5872 5871 rev, movemarkfrom = bookmarks.calculateupdate(ui, repo, rev)
5873 5872
5874 5873 # if we defined a bookmark, we have to remember the original bookmark name
5875 5874 brev = rev
5876 5875 rev = scmutil.revsingle(repo, rev, rev).rev()
5877 5876
5878 5877 if check and clean:
5879 5878 raise util.Abort(_("cannot specify both -c/--check and -C/--clean"))
5880 5879
5881 5880 if date:
5882 5881 if rev is not None:
5883 5882 raise util.Abort(_("you can't specify a revision and a date"))
5884 5883 rev = cmdutil.finddate(ui, repo, date)
5885 5884
5886 5885 if check:
5887 5886 c = repo[None]
5888 5887 if c.dirty(merge=False, branch=False, missing=True):
5889 5888 raise util.Abort(_("uncommitted changes"))
5890 5889 if rev is None:
5891 5890 rev = repo[repo[None].branch()].rev()
5892 5891 mergemod._checkunknown(repo, repo[None], repo[rev])
5893 5892
5894 5893 if clean:
5895 5894 ret = hg.clean(repo, rev)
5896 5895 else:
5897 5896 ret = hg.update(repo, rev)
5898 5897
5899 5898 if not ret and movemarkfrom:
5900 5899 if bookmarks.update(repo, [movemarkfrom], repo['.'].node()):
5901 5900 ui.status(_("updating bookmark %s\n") % repo._bookmarkcurrent)
5902 5901 elif brev in repo._bookmarks:
5903 5902 bookmarks.setcurrent(repo, brev)
5904 5903 elif brev:
5905 5904 bookmarks.unsetcurrent(repo)
5906 5905
5907 5906 return ret
5908 5907
5909 5908 @command('verify', [])
5910 5909 def verify(ui, repo):
5911 5910 """verify the integrity of the repository
5912 5911
5913 5912 Verify the integrity of the current repository.
5914 5913
5915 5914 This will perform an extensive check of the repository's
5916 5915 integrity, validating the hashes and checksums of each entry in
5917 5916 the changelog, manifest, and tracked files, as well as the
5918 5917 integrity of their crosslinks and indices.
5919 5918
5920 5919 Please see http://mercurial.selenic.com/wiki/RepositoryCorruption
5921 5920 for more information about recovery from corruption of the
5922 5921 repository.
5923 5922
5924 5923 Returns 0 on success, 1 if errors are encountered.
5925 5924 """
5926 5925 return hg.verify(repo)
5927 5926
5928 5927 @command('version', [])
5929 5928 def version_(ui):
5930 5929 """output version and copyright information"""
5931 5930 ui.write(_("Mercurial Distributed SCM (version %s)\n")
5932 5931 % util.version())
5933 5932 ui.status(_(
5934 5933 "(see http://mercurial.selenic.com for more information)\n"
5935 5934 "\nCopyright (C) 2005-2014 Matt Mackall and others\n"
5936 5935 "This is free software; see the source for copying conditions. "
5937 5936 "There is NO\nwarranty; "
5938 5937 "not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n"
5939 5938 ))
5940 5939
5941 5940 norepo = ("clone init version help debugcommands debugcomplete"
5942 5941 " debugdate debuginstall debugfsinfo debugpushkey debugwireargs"
5943 5942 " debugknown debuggetbundle debugbundle")
5944 5943 optionalrepo = ("identify paths serve config showconfig debugancestor debugdag"
5945 5944 " debugdata debugindex debugindexdot debugrevlog")
5946 5945 inferrepo = ("add addremove annotate cat commit diff grep forget log parents"
5947 5946 " remove resolve status debugwalk")
@@ -1,159 +1,159 b''
1 1 $ hg init a
2 2 $ cd a
3 3 $ echo a > a
4 4 $ hg add -n
5 5 adding a
6 6 $ hg st
7 7 ? a
8 8 $ hg add
9 9 adding a
10 10 $ hg st
11 11 A a
12 12 $ hg forget a
13 13 $ hg add
14 14 adding a
15 15 $ hg st
16 16 A a
17 17
18 18 $ echo b > b
19 19 $ hg add -n b
20 20 $ hg st
21 21 A a
22 22 ? b
23 23 $ hg add b
24 24 $ hg st
25 25 A a
26 26 A b
27 27
28 28 should fail
29 29
30 30 $ hg add b
31 31 b already tracked!
32 32 $ hg st
33 33 A a
34 34 A b
35 35
36 36 #if no-windows
37 37 $ echo foo > con.xml
38 38 $ hg --config ui.portablefilenames=jump add con.xml
39 39 abort: ui.portablefilenames value is invalid ('jump')
40 40 [255]
41 41 $ hg --config ui.portablefilenames=abort add con.xml
42 42 abort: filename contains 'con', which is reserved on Windows: 'con.xml'
43 43 [255]
44 44 $ hg st
45 45 A a
46 46 A b
47 47 ? con.xml
48 48 $ hg add con.xml
49 49 warning: filename contains 'con', which is reserved on Windows: 'con.xml'
50 50 $ hg st
51 51 A a
52 52 A b
53 53 A con.xml
54 54 $ hg forget con.xml
55 55 $ rm con.xml
56 56 #endif
57 57
58 58 #if eol-in-paths
59 59 $ echo bla > 'hello:world'
60 60 $ hg --config ui.portablefilenames=abort add
61 61 adding hello:world
62 62 abort: filename contains ':', which is reserved on Windows: 'hello:world'
63 63 [255]
64 64 $ hg st
65 65 A a
66 66 A b
67 67 ? hello:world
68 68 $ hg --config ui.portablefilenames=ignore add
69 69 adding hello:world
70 70 $ hg st
71 71 A a
72 72 A b
73 73 A hello:world
74 74 #endif
75 75
76 76 $ hg ci -m 0 --traceback
77 77
78 78 should fail
79 79
80 80 $ hg add a
81 81 a already tracked!
82 82
83 83 $ echo aa > a
84 84 $ hg ci -m 1
85 85 $ hg up 0
86 86 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
87 87 $ echo aaa > a
88 88 $ hg ci -m 2
89 89 created new head
90 90
91 91 $ hg merge
92 92 merging a
93 93 warning: conflicts during merge.
94 94 merging a incomplete! (edit conflicts, then use 'hg resolve --mark')
95 95 0 files updated, 0 files merged, 0 files removed, 1 files unresolved
96 96 use 'hg resolve' to retry unresolved file merges or 'hg update -C .' to abandon
97 97 [1]
98 98 $ hg st
99 99 M a
100 100 ? a.orig
101 101
102 102 should fail
103 103
104 104 $ hg add a
105 105 a already tracked!
106 106 $ hg st
107 107 M a
108 108 ? a.orig
109 109 $ hg resolve -m a
110 no unresolved files; you may continue your unfinished operation
110 no more unresolved files
111 111 $ hg ci -m merge
112 112
113 113 Issue683: peculiarity with hg revert of an removed then added file
114 114
115 115 $ hg forget a
116 116 $ hg add a
117 117 $ hg st
118 118 ? a.orig
119 119 $ hg rm a
120 120 $ hg st
121 121 R a
122 122 ? a.orig
123 123 $ echo a > a
124 124 $ hg add a
125 125 $ hg st
126 126 M a
127 127 ? a.orig
128 128
129 129 $ hg add c && echo "unexpected addition of missing file"
130 130 c: * (glob)
131 131 [1]
132 132 $ echo c > c
133 133 $ hg add d c && echo "unexpected addition of missing file"
134 134 d: * (glob)
135 135 [1]
136 136 $ hg st
137 137 M a
138 138 A c
139 139 ? a.orig
140 140 $ hg up -C
141 141 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
142 142
143 143 forget and get should have the right order: added but missing dir should be
144 144 forgotten before file with same name is added
145 145
146 146 $ echo file d > d
147 147 $ hg add d
148 148 $ hg ci -md
149 149 $ hg rm d
150 150 $ mkdir d
151 151 $ echo a > d/a
152 152 $ hg add d/a
153 153 $ rm -r d
154 154 $ hg up -C
155 155 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
156 156 $ cat d
157 157 file d
158 158
159 159 $ cd ..
@@ -1,517 +1,517 b''
1 1 $ hg init basic
2 2 $ cd basic
3 3
4 4 should complain
5 5
6 6 $ hg backout
7 7 abort: please specify a revision to backout
8 8 [255]
9 9 $ hg backout -r 0 0
10 10 abort: please specify just one revision
11 11 [255]
12 12
13 13 basic operation
14 14
15 15 $ echo a > a
16 16 $ hg commit -d '0 0' -A -m a
17 17 adding a
18 18 $ echo b >> a
19 19 $ hg commit -d '1 0' -m b
20 20
21 21 $ hg backout -d '2 0' tip --tool=true
22 22 reverting a
23 23 changeset 2:2929462c3dff backs out changeset 1:a820f4f40a57
24 24 $ cat a
25 25 a
26 26 $ hg summary
27 27 parent: 2:2929462c3dff tip
28 28 Backed out changeset a820f4f40a57
29 29 branch: default
30 30 commit: (clean)
31 31 update: (current)
32 32
33 33 file that was removed is recreated
34 34
35 35 $ cd ..
36 36 $ hg init remove
37 37 $ cd remove
38 38
39 39 $ echo content > a
40 40 $ hg commit -d '0 0' -A -m a
41 41 adding a
42 42
43 43 $ hg rm a
44 44 $ hg commit -d '1 0' -m b
45 45
46 46 $ hg backout -d '2 0' tip --tool=true
47 47 adding a
48 48 changeset 2:de31bdc76c0d backs out changeset 1:76862dcce372
49 49 $ cat a
50 50 content
51 51 $ hg summary
52 52 parent: 2:de31bdc76c0d tip
53 53 Backed out changeset 76862dcce372
54 54 branch: default
55 55 commit: (clean)
56 56 update: (current)
57 57
58 58 backout of backout is as if nothing happened
59 59
60 60 $ hg backout -d '3 0' --merge tip --tool=true
61 61 removing a
62 62 changeset 3:7f6d0f120113 backs out changeset 2:de31bdc76c0d
63 63 $ test -f a
64 64 [1]
65 65 $ hg summary
66 66 parent: 3:7f6d0f120113 tip
67 67 Backed out changeset de31bdc76c0d
68 68 branch: default
69 69 commit: (clean)
70 70 update: (current)
71 71
72 72 across branch
73 73
74 74 $ cd ..
75 75 $ hg init branch
76 76 $ cd branch
77 77 $ echo a > a
78 78 $ hg ci -Am0
79 79 adding a
80 80 $ echo b > b
81 81 $ hg ci -Am1
82 82 adding b
83 83 $ hg co -C 0
84 84 0 files updated, 0 files merged, 1 files removed, 0 files unresolved
85 85 $ hg summary
86 86 parent: 0:f7b1eb17ad24
87 87 0
88 88 branch: default
89 89 commit: (clean)
90 90 update: 1 new changesets (update)
91 91
92 92 should fail
93 93
94 94 $ hg backout 1
95 95 abort: cannot backout change that is not an ancestor
96 96 [255]
97 97 $ echo c > c
98 98 $ hg ci -Am2
99 99 adding c
100 100 created new head
101 101 $ hg summary
102 102 parent: 2:db815d6d32e6 tip
103 103 2
104 104 branch: default
105 105 commit: (clean)
106 106 update: 1 new changesets, 2 branch heads (merge)
107 107
108 108 should fail
109 109
110 110 $ hg backout 1
111 111 abort: cannot backout change that is not an ancestor
112 112 [255]
113 113 $ hg summary
114 114 parent: 2:db815d6d32e6 tip
115 115 2
116 116 branch: default
117 117 commit: (clean)
118 118 update: 1 new changesets, 2 branch heads (merge)
119 119
120 120 backout with merge
121 121
122 122 $ cd ..
123 123 $ hg init merge
124 124 $ cd merge
125 125
126 126 $ echo line 1 > a
127 127 $ echo line 2 >> a
128 128 $ hg commit -d '0 0' -A -m a
129 129 adding a
130 130 $ hg summary
131 131 parent: 0:59395513a13a tip
132 132 a
133 133 branch: default
134 134 commit: (clean)
135 135 update: (current)
136 136
137 137 remove line 1
138 138
139 139 $ echo line 2 > a
140 140 $ hg commit -d '1 0' -m b
141 141
142 142 $ echo line 3 >> a
143 143 $ hg commit -d '2 0' -m c
144 144
145 145 $ hg backout --merge -d '3 0' 1 --tool=true
146 146 reverting a
147 147 created new head
148 148 changeset 3:26b8ccb9ad91 backs out changeset 1:5a50a024c182
149 149 merging with changeset 3:26b8ccb9ad91
150 150 merging a
151 151 0 files updated, 1 files merged, 0 files removed, 0 files unresolved
152 152 (branch merge, don't forget to commit)
153 153 $ hg commit -d '4 0' -m d
154 154 $ hg summary
155 155 parent: 4:c7df5e0b9c09 tip
156 156 d
157 157 branch: default
158 158 commit: (clean)
159 159 update: (current)
160 160
161 161 check line 1 is back
162 162
163 163 $ cat a
164 164 line 1
165 165 line 2
166 166 line 3
167 167
168 168 $ cd ..
169 169
170 170 backout should not back out subsequent changesets
171 171
172 172 $ hg init onecs
173 173 $ cd onecs
174 174 $ echo 1 > a
175 175 $ hg commit -d '0 0' -A -m a
176 176 adding a
177 177 $ echo 2 >> a
178 178 $ hg commit -d '1 0' -m b
179 179 $ echo 1 > b
180 180 $ hg commit -d '2 0' -A -m c
181 181 adding b
182 182 $ hg summary
183 183 parent: 2:882396649954 tip
184 184 c
185 185 branch: default
186 186 commit: (clean)
187 187 update: (current)
188 188
189 189 without --merge
190 190 $ hg backout -d '3 0' 1 --tool=true
191 191 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
192 192 changeset 22bca4c721e5 backed out, don't forget to commit.
193 193 $ hg locate b
194 194 b
195 195 $ hg update -C tip
196 196 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
197 197 $ hg locate b
198 198 b
199 199 $ hg summary
200 200 parent: 2:882396649954 tip
201 201 c
202 202 branch: default
203 203 commit: (clean)
204 204 update: (current)
205 205
206 206 with --merge
207 207 $ hg backout --merge -d '3 0' 1 --tool=true
208 208 reverting a
209 209 created new head
210 210 changeset 3:3202beb76721 backs out changeset 1:22bca4c721e5
211 211 merging with changeset 3:3202beb76721
212 212 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
213 213 (branch merge, don't forget to commit)
214 214 $ hg locate b
215 215 b
216 216 $ hg update -C tip
217 217 1 files updated, 0 files merged, 1 files removed, 0 files unresolved
218 218 $ hg locate b
219 219 [1]
220 220
221 221 $ cd ..
222 222 $ hg init m
223 223 $ cd m
224 224 $ echo a > a
225 225 $ hg commit -d '0 0' -A -m a
226 226 adding a
227 227 $ echo b > b
228 228 $ hg commit -d '1 0' -A -m b
229 229 adding b
230 230 $ echo c > c
231 231 $ hg commit -d '2 0' -A -m b
232 232 adding c
233 233 $ hg update 1
234 234 0 files updated, 0 files merged, 1 files removed, 0 files unresolved
235 235 $ echo d > d
236 236 $ hg commit -d '3 0' -A -m c
237 237 adding d
238 238 created new head
239 239 $ hg merge 2
240 240 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
241 241 (branch merge, don't forget to commit)
242 242 $ hg commit -d '4 0' -A -m d
243 243 $ hg summary
244 244 parent: 4:b2f3bb92043e tip
245 245 d
246 246 branch: default
247 247 commit: (clean)
248 248 update: (current)
249 249
250 250 backout of merge should fail
251 251
252 252 $ hg backout 4
253 253 abort: cannot backout a merge changeset
254 254 [255]
255 255
256 256 backout of merge with bad parent should fail
257 257
258 258 $ hg backout --parent 0 4
259 259 abort: cb9a9f314b8b is not a parent of b2f3bb92043e
260 260 [255]
261 261
262 262 backout of non-merge with parent should fail
263 263
264 264 $ hg backout --parent 0 3
265 265 abort: cannot use --parent on non-merge changeset
266 266 [255]
267 267
268 268 backout with valid parent should be ok
269 269
270 270 $ hg backout -d '5 0' --parent 2 4 --tool=true
271 271 removing d
272 272 changeset 5:10e5328c8435 backs out changeset 4:b2f3bb92043e
273 273 $ hg summary
274 274 parent: 5:10e5328c8435 tip
275 275 Backed out changeset b2f3bb92043e
276 276 branch: default
277 277 commit: (clean)
278 278 update: (current)
279 279
280 280 $ hg rollback
281 281 repository tip rolled back to revision 4 (undo commit)
282 282 working directory now based on revision 4
283 283 $ hg update -C
284 284 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
285 285 $ hg summary
286 286 parent: 4:b2f3bb92043e tip
287 287 d
288 288 branch: default
289 289 commit: (clean)
290 290 update: (current)
291 291
292 292 $ hg backout -d '6 0' --parent 3 4 --tool=true
293 293 removing c
294 294 changeset 5:033590168430 backs out changeset 4:b2f3bb92043e
295 295 $ hg summary
296 296 parent: 5:033590168430 tip
297 297 Backed out changeset b2f3bb92043e
298 298 branch: default
299 299 commit: (clean)
300 300 update: (current)
301 301
302 302 $ cd ..
303 303
304 304 named branches
305 305
306 306 $ hg init named_branches
307 307 $ cd named_branches
308 308
309 309 $ echo default > default
310 310 $ hg ci -d '0 0' -Am default
311 311 adding default
312 312 $ hg branch branch1
313 313 marked working directory as branch branch1
314 314 (branches are permanent and global, did you want a bookmark?)
315 315 $ echo branch1 > file1
316 316 $ hg ci -d '1 0' -Am file1
317 317 adding file1
318 318 $ hg branch branch2
319 319 marked working directory as branch branch2
320 320 (branches are permanent and global, did you want a bookmark?)
321 321 $ echo branch2 > file2
322 322 $ hg ci -d '2 0' -Am file2
323 323 adding file2
324 324
325 325 without --merge
326 326 $ hg backout -r 1 --tool=true
327 327 0 files updated, 0 files merged, 1 files removed, 0 files unresolved
328 328 changeset bf1602f437f3 backed out, don't forget to commit.
329 329 $ hg branch
330 330 branch2
331 331 $ hg status -A
332 332 R file1
333 333 C default
334 334 C file2
335 335 $ hg summary
336 336 parent: 2:45bbcd363bf0 tip
337 337 file2
338 338 branch: branch2
339 339 commit: 1 removed
340 340 update: (current)
341 341
342 342 with --merge
343 343 $ hg update -qC
344 344 $ hg backout --merge -d '3 0' -r 1 -m 'backout on branch1' --tool=true
345 345 removing file1
346 346 created new head
347 347 changeset 3:d4e8f6db59fb backs out changeset 1:bf1602f437f3
348 348 merging with changeset 3:d4e8f6db59fb
349 349 0 files updated, 0 files merged, 1 files removed, 0 files unresolved
350 350 (branch merge, don't forget to commit)
351 351 $ hg summary
352 352 parent: 2:45bbcd363bf0
353 353 file2
354 354 parent: 3:d4e8f6db59fb tip
355 355 backout on branch1
356 356 branch: branch2
357 357 commit: 1 removed (merge)
358 358 update: (current)
359 359 $ hg update -q -C 2
360 360
361 361 on branch2 with branch1 not merged, so file1 should still exist:
362 362
363 363 $ hg id
364 364 45bbcd363bf0 (branch2)
365 365 $ hg st -A
366 366 C default
367 367 C file1
368 368 C file2
369 369 $ hg summary
370 370 parent: 2:45bbcd363bf0
371 371 file2
372 372 branch: branch2
373 373 commit: (clean)
374 374 update: 1 new changesets, 2 branch heads (merge)
375 375
376 376 on branch2 with branch1 merged, so file1 should be gone:
377 377
378 378 $ hg merge
379 379 0 files updated, 0 files merged, 1 files removed, 0 files unresolved
380 380 (branch merge, don't forget to commit)
381 381 $ hg ci -d '4 0' -m 'merge backout of branch1'
382 382 $ hg id
383 383 22149cdde76d (branch2) tip
384 384 $ hg st -A
385 385 C default
386 386 C file2
387 387 $ hg summary
388 388 parent: 4:22149cdde76d tip
389 389 merge backout of branch1
390 390 branch: branch2
391 391 commit: (clean)
392 392 update: (current)
393 393
394 394 on branch1, so no file1 and file2:
395 395
396 396 $ hg co -C branch1
397 397 1 files updated, 0 files merged, 1 files removed, 0 files unresolved
398 398 $ hg id
399 399 bf1602f437f3 (branch1)
400 400 $ hg st -A
401 401 C default
402 402 C file1
403 403 $ hg summary
404 404 parent: 1:bf1602f437f3
405 405 file1
406 406 branch: branch1
407 407 commit: (clean)
408 408 update: (current)
409 409
410 410 $ cd ..
411 411
412 412 backout of empty changeset (issue4190)
413 413
414 414 $ hg init emptycommit
415 415 $ cd emptycommit
416 416
417 417 $ touch file1
418 418 $ hg ci -Aqm file1
419 419 $ hg branch -q branch1
420 420 $ hg ci -qm branch1
421 421 $ hg backout -v 1
422 422 resolving manifests
423 423 nothing changed
424 424 [1]
425 425
426 426 $ cd ..
427 427
428 428
429 429 Test usage of `hg resolve` in case of conflict
430 430 (issue4163)
431 431
432 432 $ hg init issue4163
433 433 $ cd issue4163
434 434 $ touch foo
435 435 $ hg add foo
436 436 $ cat > foo << EOF
437 437 > one
438 438 > two
439 439 > three
440 440 > four
441 441 > five
442 442 > six
443 443 > seven
444 444 > height
445 445 > nine
446 446 > ten
447 447 > EOF
448 448 $ hg ci -m 'initial'
449 449 $ cat > foo << EOF
450 450 > one
451 451 > two
452 452 > THREE
453 453 > four
454 454 > five
455 455 > six
456 456 > seven
457 457 > height
458 458 > nine
459 459 > ten
460 460 > EOF
461 461 $ hg ci -m 'capital three'
462 462 $ cat > foo << EOF
463 463 > one
464 464 > two
465 465 > THREE
466 466 > four
467 467 > five
468 468 > six
469 469 > seven
470 470 > height
471 471 > nine
472 472 > TEN
473 473 > EOF
474 474 $ hg ci -m 'capital ten'
475 475 $ hg backout -r 'desc("capital three")' --tool internal:fail
476 476 0 files updated, 0 files merged, 0 files removed, 1 files unresolved
477 477 use 'hg resolve' to retry unresolved file merges
478 478 [1]
479 479 $ hg status
480 480 $ hg resolve -l # still unresolved
481 481 U foo
482 482 $ hg summary
483 483 parent: 2:b71750c4b0fd tip
484 484 capital ten
485 485 branch: default
486 486 commit: 1 unresolved (clean)
487 487 update: (current)
488 488 $ hg resolve --all --debug
489 489 picked tool 'internal:merge' for foo (binary False symlink False)
490 490 merging foo
491 491 my foo@b71750c4b0fd+ other foo@a30dd8addae3 ancestor foo@913609522437
492 492 premerge successful
493 no unresolved files; you may continue your unfinished operation
493 no more unresolved files
494 494 $ hg status
495 495 M foo
496 496 ? foo.orig
497 497 $ hg resolve -l
498 498 R foo
499 499 $ hg summary
500 500 parent: 2:b71750c4b0fd tip
501 501 capital ten
502 502 branch: default
503 503 commit: 1 modified, 1 unknown
504 504 update: (current)
505 505 $ cat foo
506 506 one
507 507 two
508 508 three
509 509 four
510 510 five
511 511 six
512 512 seven
513 513 height
514 514 nine
515 515 TEN
516 516
517 517
@@ -1,852 +1,852 b''
1 1 $ hg init
2 2
3 3 Setup:
4 4
5 5 $ echo a >> a
6 6 $ hg ci -Am 'base'
7 7 adding a
8 8
9 9 Refuse to amend public csets:
10 10
11 11 $ hg phase -r . -p
12 12 $ hg ci --amend
13 13 abort: cannot amend public changesets
14 14 [255]
15 15 $ hg phase -r . -f -d
16 16
17 17 $ echo a >> a
18 18 $ hg ci -Am 'base1'
19 19
20 20 Nothing to amend:
21 21
22 22 $ hg ci --amend
23 23 nothing changed
24 24 [1]
25 25
26 26 $ cat >> $HGRCPATH <<EOF
27 27 > [hooks]
28 28 > pretxncommit.foo = sh -c "echo \\"pretxncommit \$HG_NODE\\"; hg id -r \$HG_NODE"
29 29 > EOF
30 30
31 31 Amending changeset with changes in working dir:
32 32 (and check that --message does not trigger an editor)
33 33
34 34 $ echo a >> a
35 35 $ HGEDITOR="\"sh\" \"`pwd`/editor.sh\"" hg commit --amend -m 'amend base1'
36 36 pretxncommit 43f1ba15f28a50abf0aae529cf8a16bfced7b149
37 37 43f1ba15f28a tip
38 38 saved backup bundle to $TESTTMP/.hg/strip-backup/489edb5b847d-amend-backup.hg (glob)
39 39 $ echo 'pretxncommit.foo = ' >> $HGRCPATH
40 40 $ hg diff -c .
41 41 diff -r ad120869acf0 -r 43f1ba15f28a a
42 42 --- a/a Thu Jan 01 00:00:00 1970 +0000
43 43 +++ b/a Thu Jan 01 00:00:00 1970 +0000
44 44 @@ -1,1 +1,3 @@
45 45 a
46 46 +a
47 47 +a
48 48 $ hg log
49 49 changeset: 1:43f1ba15f28a
50 50 tag: tip
51 51 user: test
52 52 date: Thu Jan 01 00:00:00 1970 +0000
53 53 summary: amend base1
54 54
55 55 changeset: 0:ad120869acf0
56 56 user: test
57 57 date: Thu Jan 01 00:00:00 1970 +0000
58 58 summary: base
59 59
60 60
61 61 Check proper abort for empty message
62 62
63 63 $ cat > editor.sh << '__EOF__'
64 64 > #!/bin/sh
65 65 > echo "" > "$1"
66 66 > __EOF__
67 67 $ echo b > b
68 68 $ hg add b
69 69 $ hg summary
70 70 parent: 1:43f1ba15f28a tip
71 71 amend base1
72 72 branch: default
73 73 commit: 1 added, 1 unknown
74 74 update: (current)
75 75 $ HGEDITOR="\"sh\" \"`pwd`/editor.sh\"" hg commit --amend
76 76 transaction abort!
77 77 rollback completed
78 78 abort: empty commit message
79 79 [255]
80 80 $ hg summary
81 81 parent: 1:43f1ba15f28a tip
82 82 amend base1
83 83 branch: default
84 84 commit: 1 added, 1 unknown
85 85 update: (current)
86 86
87 87 Add new file:
88 88 $ hg ci --amend -m 'amend base1 new file'
89 89 saved backup bundle to $TESTTMP/.hg/strip-backup/43f1ba15f28a-amend-backup.hg (glob)
90 90
91 91 Remove file that was added in amended commit:
92 92 (and test logfile option)
93 93 (and test that logfile option do not trigger an editor)
94 94
95 95 $ hg rm b
96 96 $ echo 'amend base1 remove new file' > ../logfile
97 97 $ HGEDITOR="\"sh\" \"`pwd`/editor.sh\"" hg ci --amend --logfile ../logfile
98 98 saved backup bundle to $TESTTMP/.hg/strip-backup/b8e3cb2b3882-amend-backup.hg (glob)
99 99
100 100 $ hg cat b
101 101 b: no such file in rev 74609c7f506e
102 102 [1]
103 103
104 104 No changes, just a different message:
105 105
106 106 $ hg ci -v --amend -m 'no changes, new message'
107 107 amending changeset 74609c7f506e
108 108 copying changeset 74609c7f506e to ad120869acf0
109 109 a
110 110 stripping amended changeset 74609c7f506e
111 111 1 changesets found
112 112 saved backup bundle to $TESTTMP/.hg/strip-backup/74609c7f506e-amend-backup.hg (glob)
113 113 1 changesets found
114 114 adding branch
115 115 adding changesets
116 116 adding manifests
117 117 adding file changes
118 118 added 1 changesets with 1 changes to 1 files
119 119 committed changeset 1:1cd866679df8
120 120 $ hg diff -c .
121 121 diff -r ad120869acf0 -r 1cd866679df8 a
122 122 --- a/a Thu Jan 01 00:00:00 1970 +0000
123 123 +++ b/a Thu Jan 01 00:00:00 1970 +0000
124 124 @@ -1,1 +1,3 @@
125 125 a
126 126 +a
127 127 +a
128 128 $ hg log
129 129 changeset: 1:1cd866679df8
130 130 tag: tip
131 131 user: test
132 132 date: Thu Jan 01 00:00:00 1970 +0000
133 133 summary: no changes, new message
134 134
135 135 changeset: 0:ad120869acf0
136 136 user: test
137 137 date: Thu Jan 01 00:00:00 1970 +0000
138 138 summary: base
139 139
140 140
141 141 Disable default date on commit so when -d isn't given, the old date is preserved:
142 142
143 143 $ echo '[defaults]' >> $HGRCPATH
144 144 $ echo 'commit=' >> $HGRCPATH
145 145
146 146 Test -u/-d:
147 147
148 148 $ hg ci --amend -u foo -d '1 0'
149 149 saved backup bundle to $TESTTMP/.hg/strip-backup/1cd866679df8-amend-backup.hg (glob)
150 150 $ echo a >> a
151 151 $ hg ci --amend -u foo -d '1 0'
152 152 saved backup bundle to $TESTTMP/.hg/strip-backup/780e6f23e03d-amend-backup.hg (glob)
153 153 $ hg log -r .
154 154 changeset: 1:5f357c7560ab
155 155 tag: tip
156 156 user: foo
157 157 date: Thu Jan 01 00:00:01 1970 +0000
158 158 summary: no changes, new message
159 159
160 160
161 161 Open editor with old commit message if a message isn't given otherwise:
162 162
163 163 $ cat > editor.sh << '__EOF__'
164 164 > #!/bin/sh
165 165 > cat $1
166 166 > echo "another precious commit message" > "$1"
167 167 > __EOF__
168 168
169 169 at first, test saving last-message.txt
170 170
171 171 $ cat > .hg/hgrc << '__EOF__'
172 172 > [hooks]
173 173 > pretxncommit.test-saving-last-message = false
174 174 > __EOF__
175 175
176 176 $ rm -f .hg/last-message.txt
177 177 $ hg commit --amend -v -m "message given from command line"
178 178 amending changeset 5f357c7560ab
179 179 copying changeset 5f357c7560ab to ad120869acf0
180 180 a
181 181 running hook pretxncommit.test-saving-last-message: false
182 182 transaction abort!
183 183 rollback completed
184 184 abort: pretxncommit.test-saving-last-message hook exited with status 1
185 185 [255]
186 186 $ cat .hg/last-message.txt
187 187 message given from command line (no-eol)
188 188
189 189 $ rm -f .hg/last-message.txt
190 190 $ HGEDITOR="\"sh\" \"`pwd`/editor.sh\"" hg commit --amend -v
191 191 amending changeset 5f357c7560ab
192 192 copying changeset 5f357c7560ab to ad120869acf0
193 193 no changes, new message
194 194
195 195
196 196 HG: Enter commit message. Lines beginning with 'HG:' are removed.
197 197 HG: Leave message empty to abort commit.
198 198 HG: --
199 199 HG: user: foo
200 200 HG: branch 'default'
201 201 HG: changed a
202 202 a
203 203 running hook pretxncommit.test-saving-last-message: false
204 204 transaction abort!
205 205 rollback completed
206 206 abort: pretxncommit.test-saving-last-message hook exited with status 1
207 207 [255]
208 208
209 209 $ cat .hg/last-message.txt
210 210 another precious commit message
211 211
212 212 $ cat > .hg/hgrc << '__EOF__'
213 213 > [hooks]
214 214 > pretxncommit.test-saving-last-message =
215 215 > __EOF__
216 216
217 217 then, test editing custom commit message
218 218
219 219 $ HGEDITOR="\"sh\" \"`pwd`/editor.sh\"" hg commit --amend -v
220 220 amending changeset 5f357c7560ab
221 221 copying changeset 5f357c7560ab to ad120869acf0
222 222 no changes, new message
223 223
224 224
225 225 HG: Enter commit message. Lines beginning with 'HG:' are removed.
226 226 HG: Leave message empty to abort commit.
227 227 HG: --
228 228 HG: user: foo
229 229 HG: branch 'default'
230 230 HG: changed a
231 231 a
232 232 stripping amended changeset 5f357c7560ab
233 233 1 changesets found
234 234 saved backup bundle to $TESTTMP/.hg/strip-backup/5f357c7560ab-amend-backup.hg (glob)
235 235 1 changesets found
236 236 adding branch
237 237 adding changesets
238 238 adding manifests
239 239 adding file changes
240 240 added 1 changesets with 1 changes to 1 files
241 241 committed changeset 1:7ab3bf440b54
242 242
243 243 Same, but with changes in working dir (different code path):
244 244
245 245 $ echo a >> a
246 246 $ HGEDITOR="\"sh\" \"`pwd`/editor.sh\"" hg commit --amend -v
247 247 amending changeset 7ab3bf440b54
248 248 a
249 249 copying changeset a0ea9b1a4c8c to ad120869acf0
250 250 another precious commit message
251 251
252 252
253 253 HG: Enter commit message. Lines beginning with 'HG:' are removed.
254 254 HG: Leave message empty to abort commit.
255 255 HG: --
256 256 HG: user: foo
257 257 HG: branch 'default'
258 258 HG: changed a
259 259 a
260 260 stripping intermediate changeset a0ea9b1a4c8c
261 261 stripping amended changeset 7ab3bf440b54
262 262 2 changesets found
263 263 saved backup bundle to $TESTTMP/.hg/strip-backup/7ab3bf440b54-amend-backup.hg (glob)
264 264 1 changesets found
265 265 adding branch
266 266 adding changesets
267 267 adding manifests
268 268 adding file changes
269 269 added 1 changesets with 1 changes to 1 files
270 270 committed changeset 1:ea22a388757c
271 271
272 272 $ rm editor.sh
273 273 $ hg log -r .
274 274 changeset: 1:ea22a388757c
275 275 tag: tip
276 276 user: foo
277 277 date: Thu Jan 01 00:00:01 1970 +0000
278 278 summary: another precious commit message
279 279
280 280
281 281 Moving bookmarks, preserve active bookmark:
282 282
283 283 $ hg book book1
284 284 $ hg book book2
285 285 $ hg ci --amend -m 'move bookmarks'
286 286 saved backup bundle to $TESTTMP/.hg/strip-backup/ea22a388757c-amend-backup.hg (glob)
287 287 $ hg book
288 288 book1 1:6cec5aa930e2
289 289 * book2 1:6cec5aa930e2
290 290 $ echo a >> a
291 291 $ hg ci --amend -m 'move bookmarks'
292 292 saved backup bundle to $TESTTMP/.hg/strip-backup/6cec5aa930e2-amend-backup.hg (glob)
293 293 $ hg book
294 294 book1 1:48bb6e53a15f
295 295 * book2 1:48bb6e53a15f
296 296
297 297 abort does not loose bookmarks
298 298
299 299 $ cat > editor.sh << '__EOF__'
300 300 > #!/bin/sh
301 301 > echo "" > "$1"
302 302 > __EOF__
303 303 $ echo a >> a
304 304 $ HGEDITOR="\"sh\" \"`pwd`/editor.sh\"" hg commit --amend
305 305 transaction abort!
306 306 rollback completed
307 307 abort: empty commit message
308 308 [255]
309 309 $ hg book
310 310 book1 1:48bb6e53a15f
311 311 * book2 1:48bb6e53a15f
312 312 $ hg revert -Caq
313 313 $ rm editor.sh
314 314
315 315 $ echo '[defaults]' >> $HGRCPATH
316 316 $ echo "commit=-d '0 0'" >> $HGRCPATH
317 317
318 318 Moving branches:
319 319
320 320 $ hg branch foo
321 321 marked working directory as branch foo
322 322 (branches are permanent and global, did you want a bookmark?)
323 323 $ echo a >> a
324 324 $ hg ci -m 'branch foo'
325 325 $ hg branch default -f
326 326 marked working directory as branch default
327 327 (branches are permanent and global, did you want a bookmark?)
328 328 $ hg ci --amend -m 'back to default'
329 329 saved backup bundle to $TESTTMP/.hg/strip-backup/8ac881fbf49d-amend-backup.hg (glob)
330 330 $ hg branches
331 331 default 2:ce12b0b57d46
332 332
333 333 Close branch:
334 334
335 335 $ hg up -q 0
336 336 $ echo b >> b
337 337 $ hg branch foo
338 338 marked working directory as branch foo
339 339 (branches are permanent and global, did you want a bookmark?)
340 340 $ hg ci -Am 'fork'
341 341 adding b
342 342 $ echo b >> b
343 343 $ hg ci -mb
344 344 $ hg ci --amend --close-branch -m 'closing branch foo'
345 345 saved backup bundle to $TESTTMP/.hg/strip-backup/c962248fa264-amend-backup.hg (glob)
346 346
347 347 Same thing, different code path:
348 348
349 349 $ echo b >> b
350 350 $ hg ci -m 'reopen branch'
351 351 reopening closed branch head 4
352 352 $ echo b >> b
353 353 $ hg ci --amend --close-branch
354 354 saved backup bundle to $TESTTMP/.hg/strip-backup/027371728205-amend-backup.hg (glob)
355 355 $ hg branches
356 356 default 2:ce12b0b57d46
357 357
358 358 Refuse to amend during a merge:
359 359
360 360 $ hg up -q default
361 361 $ hg merge foo
362 362 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
363 363 (branch merge, don't forget to commit)
364 364 $ hg ci --amend
365 365 abort: cannot amend while merging
366 366 [255]
367 367 $ hg ci -m 'merge'
368 368
369 369 Follow copies/renames:
370 370
371 371 $ hg mv b c
372 372 $ hg ci -m 'b -> c'
373 373 $ hg mv c d
374 374 $ hg ci --amend -m 'b -> d'
375 375 saved backup bundle to $TESTTMP/.hg/strip-backup/b8c6eac7f12e-amend-backup.hg (glob)
376 376 $ hg st --rev '.^' --copies d
377 377 A d
378 378 b
379 379 $ hg cp d e
380 380 $ hg ci -m 'e = d'
381 381 $ hg cp e f
382 382 $ hg ci --amend -m 'f = d'
383 383 saved backup bundle to $TESTTMP/.hg/strip-backup/7f9761d65613-amend-backup.hg (glob)
384 384 $ hg st --rev '.^' --copies f
385 385 A f
386 386 d
387 387
388 388 $ mv f f.orig
389 389 $ hg rm -A f
390 390 $ hg ci -m removef
391 391 $ hg cp a f
392 392 $ mv f.orig f
393 393 $ hg ci --amend -m replacef
394 394 saved backup bundle to $TESTTMP/.hg/strip-backup/9e8c5f7e3d95-amend-backup.hg (glob)
395 395 $ hg st --change . --copies
396 396 $ hg log -r . --template "{file_copies}\n"
397 397
398 398
399 399 Move added file (issue3410):
400 400
401 401 $ echo g >> g
402 402 $ hg ci -Am g
403 403 adding g
404 404 $ hg mv g h
405 405 $ hg ci --amend
406 406 saved backup bundle to $TESTTMP/.hg/strip-backup/24aa8eacce2b-amend-backup.hg (glob)
407 407 $ hg st --change . --copies h
408 408 A h
409 409 $ hg log -r . --template "{file_copies}\n"
410 410
411 411
412 412 Can't rollback an amend:
413 413
414 414 $ hg rollback
415 415 no rollback information available
416 416 [1]
417 417
418 418 Preserve extra dict (issue3430):
419 419
420 420 $ hg branch a
421 421 marked working directory as branch a
422 422 (branches are permanent and global, did you want a bookmark?)
423 423 $ echo a >> a
424 424 $ hg ci -ma
425 425 $ hg ci --amend -m "a'"
426 426 saved backup bundle to $TESTTMP/.hg/strip-backup/3837aa2a2fdb-amend-backup.hg (glob)
427 427 $ hg log -r . --template "{branch}\n"
428 428 a
429 429 $ hg ci --amend -m "a''"
430 430 saved backup bundle to $TESTTMP/.hg/strip-backup/c05c06be7514-amend-backup.hg (glob)
431 431 $ hg log -r . --template "{branch}\n"
432 432 a
433 433
434 434 Also preserve other entries in the dict that are in the old commit,
435 435 first graft something so there's an additional entry:
436 436
437 437 $ hg up 0 -q
438 438 $ echo z > z
439 439 $ hg ci -Am 'fork'
440 440 adding z
441 441 created new head
442 442 $ hg up 11
443 443 5 files updated, 0 files merged, 1 files removed, 0 files unresolved
444 444 $ hg graft 12
445 445 grafting revision 12
446 446 $ hg ci --amend -m 'graft amend'
447 447 saved backup bundle to $TESTTMP/.hg/strip-backup/bd010aea3f39-amend-backup.hg (glob)
448 448 $ hg log -r . --debug | grep extra
449 449 extra: amend_source=bd010aea3f39f3fb2a2f884b9ccb0471cd77398e
450 450 extra: branch=a
451 451 extra: source=2647734878ef0236dda712fae9c1651cf694ea8a
452 452
453 453 Preserve phase
454 454
455 455 $ hg phase '.^::.'
456 456 11: draft
457 457 13: draft
458 458 $ hg phase --secret --force .
459 459 $ hg phase '.^::.'
460 460 11: draft
461 461 13: secret
462 462 $ hg commit --amend -m 'amend for phase' -q
463 463 $ hg phase '.^::.'
464 464 11: draft
465 465 13: secret
466 466
467 467 Test amend with obsolete
468 468 ---------------------------
469 469
470 470 Enable obsolete
471 471
472 472 $ cat > ${TESTTMP}/obs.py << EOF
473 473 > import mercurial.obsolete
474 474 > mercurial.obsolete._enabled = True
475 475 > EOF
476 476 $ echo '[extensions]' >> $HGRCPATH
477 477 $ echo "obs=${TESTTMP}/obs.py" >> $HGRCPATH
478 478
479 479
480 480 Amend with no files changes
481 481
482 482 $ hg id -n
483 483 13
484 484 $ hg ci --amend -m 'babar'
485 485 $ hg id -n
486 486 14
487 487 $ hg log -Gl 3 --style=compact
488 488 @ 14[tip]:11 b650e6ee8614 1970-01-01 00:00 +0000 test
489 489 | babar
490 490 |
491 491 | o 12:0 2647734878ef 1970-01-01 00:00 +0000 test
492 492 | | fork
493 493 | |
494 494 o | 11 3334b7925910 1970-01-01 00:00 +0000 test
495 495 | | a''
496 496 | |
497 497 $ hg log -Gl 4 --hidden --style=compact
498 498 @ 14[tip]:11 b650e6ee8614 1970-01-01 00:00 +0000 test
499 499 | babar
500 500 |
501 501 | x 13:11 68ff8ff97044 1970-01-01 00:00 +0000 test
502 502 |/ amend for phase
503 503 |
504 504 | o 12:0 2647734878ef 1970-01-01 00:00 +0000 test
505 505 | | fork
506 506 | |
507 507 o | 11 3334b7925910 1970-01-01 00:00 +0000 test
508 508 | | a''
509 509 | |
510 510
511 511 Amend with files changes
512 512
513 513 (note: the extra commit over 15 is a temporary junk I would be happy to get
514 514 ride of)
515 515
516 516 $ echo 'babar' >> a
517 517 $ hg commit --amend
518 518 $ hg log -Gl 6 --hidden --style=compact
519 519 @ 16[tip]:11 9f9e9bccf56c 1970-01-01 00:00 +0000 test
520 520 | babar
521 521 |
522 522 | x 15 90fef497c56f 1970-01-01 00:00 +0000 test
523 523 | | temporary amend commit for b650e6ee8614
524 524 | |
525 525 | x 14:11 b650e6ee8614 1970-01-01 00:00 +0000 test
526 526 |/ babar
527 527 |
528 528 | x 13:11 68ff8ff97044 1970-01-01 00:00 +0000 test
529 529 |/ amend for phase
530 530 |
531 531 | o 12:0 2647734878ef 1970-01-01 00:00 +0000 test
532 532 | | fork
533 533 | |
534 534 o | 11 3334b7925910 1970-01-01 00:00 +0000 test
535 535 | | a''
536 536 | |
537 537
538 538
539 539 Test that amend does not make it easy to create obsolescence cycle
540 540 ---------------------------------------------------------------------
541 541
542 542 $ hg id -r 14 --hidden
543 543 b650e6ee8614 (a)
544 544 $ hg revert -ar 14 --hidden
545 545 reverting a
546 546 $ hg commit --amend
547 547 $ hg id
548 548 b99e5df575f7 (a) tip
549 549
550 550 Test that rewriting leaving instability behind is allowed
551 551 ---------------------------------------------------------------------
552 552
553 553 $ hg up '.^'
554 554 0 files updated, 0 files merged, 1 files removed, 0 files unresolved
555 555 $ echo 'b' >> a
556 556 $ hg log --style compact -r 'children(.)'
557 557 18[tip]:11 b99e5df575f7 1970-01-01 00:00 +0000 test
558 558 babar
559 559
560 560 $ hg commit --amend
561 561 $ hg log -r 'unstable()'
562 562 changeset: 18:b99e5df575f7
563 563 branch: a
564 564 parent: 11:3334b7925910
565 565 user: test
566 566 date: Thu Jan 01 00:00:00 1970 +0000
567 567 summary: babar
568 568
569 569
570 570 Amend a merge changeset (with renames and conflicts from the second parent):
571 571
572 572 $ hg up -q default
573 573 $ hg branch -q bar
574 574 $ hg cp a aa
575 575 $ hg mv z zz
576 576 $ echo cc > cc
577 577 $ hg add cc
578 578 $ hg ci -m aazzcc
579 579 $ hg up -q default
580 580 $ echo a >> a
581 581 $ echo dd > cc
582 582 $ hg add cc
583 583 $ hg ci -m aa
584 584 $ hg merge -q bar
585 585 warning: conflicts during merge.
586 586 merging cc incomplete! (edit conflicts, then use 'hg resolve --mark')
587 587 [1]
588 588 $ hg resolve -m cc
589 no unresolved files; you may continue your unfinished operation
589 no more unresolved files
590 590 $ hg ci -m 'merge bar'
591 591 $ hg log --config diff.git=1 -pr .
592 592 changeset: 23:d51446492733
593 593 tag: tip
594 594 parent: 22:30d96aeaf27b
595 595 parent: 21:1aa437659d19
596 596 user: test
597 597 date: Thu Jan 01 00:00:00 1970 +0000
598 598 summary: merge bar
599 599
600 600 diff --git a/a b/aa
601 601 copy from a
602 602 copy to aa
603 603 diff --git a/cc b/cc
604 604 --- a/cc
605 605 +++ b/cc
606 606 @@ -1,1 +1,5 @@
607 607 +<<<<<<< local
608 608 dd
609 609 +=======
610 610 +cc
611 611 +>>>>>>> other
612 612 diff --git a/z b/zz
613 613 rename from z
614 614 rename to zz
615 615
616 616 $ hg debugrename aa
617 617 aa renamed from a:a80d06849b333b8a3d5c445f8ba3142010dcdc9e
618 618 $ hg debugrename zz
619 619 zz renamed from z:69a1b67522704ec122181c0890bd16e9d3e7516a
620 620 $ hg debugrename cc
621 621 cc not renamed
622 622 $ hg ci --amend -m 'merge bar (amend message)'
623 623 $ hg log --config diff.git=1 -pr .
624 624 changeset: 24:59de3dce7a79
625 625 tag: tip
626 626 parent: 22:30d96aeaf27b
627 627 parent: 21:1aa437659d19
628 628 user: test
629 629 date: Thu Jan 01 00:00:00 1970 +0000
630 630 summary: merge bar (amend message)
631 631
632 632 diff --git a/a b/aa
633 633 copy from a
634 634 copy to aa
635 635 diff --git a/cc b/cc
636 636 --- a/cc
637 637 +++ b/cc
638 638 @@ -1,1 +1,5 @@
639 639 +<<<<<<< local
640 640 dd
641 641 +=======
642 642 +cc
643 643 +>>>>>>> other
644 644 diff --git a/z b/zz
645 645 rename from z
646 646 rename to zz
647 647
648 648 $ hg debugrename aa
649 649 aa renamed from a:a80d06849b333b8a3d5c445f8ba3142010dcdc9e
650 650 $ hg debugrename zz
651 651 zz renamed from z:69a1b67522704ec122181c0890bd16e9d3e7516a
652 652 $ hg debugrename cc
653 653 cc not renamed
654 654 $ hg mv zz z
655 655 $ hg ci --amend -m 'merge bar (undo rename)'
656 656 $ hg log --config diff.git=1 -pr .
657 657 changeset: 26:7fb89c461f81
658 658 tag: tip
659 659 parent: 22:30d96aeaf27b
660 660 parent: 21:1aa437659d19
661 661 user: test
662 662 date: Thu Jan 01 00:00:00 1970 +0000
663 663 summary: merge bar (undo rename)
664 664
665 665 diff --git a/a b/aa
666 666 copy from a
667 667 copy to aa
668 668 diff --git a/cc b/cc
669 669 --- a/cc
670 670 +++ b/cc
671 671 @@ -1,1 +1,5 @@
672 672 +<<<<<<< local
673 673 dd
674 674 +=======
675 675 +cc
676 676 +>>>>>>> other
677 677
678 678 $ hg debugrename z
679 679 z not renamed
680 680
681 681 Amend a merge changeset (with renames during the merge):
682 682
683 683 $ hg up -q bar
684 684 $ echo x > x
685 685 $ hg add x
686 686 $ hg ci -m x
687 687 $ hg up -q default
688 688 $ hg merge -q bar
689 689 $ hg mv aa aaa
690 690 $ echo aa >> aaa
691 691 $ hg ci -m 'merge bar again'
692 692 $ hg log --config diff.git=1 -pr .
693 693 changeset: 28:982d7a34ffee
694 694 tag: tip
695 695 parent: 26:7fb89c461f81
696 696 parent: 27:4c94d5bc65f5
697 697 user: test
698 698 date: Thu Jan 01 00:00:00 1970 +0000
699 699 summary: merge bar again
700 700
701 701 diff --git a/aa b/aa
702 702 deleted file mode 100644
703 703 --- a/aa
704 704 +++ /dev/null
705 705 @@ -1,2 +0,0 @@
706 706 -a
707 707 -a
708 708 diff --git a/aaa b/aaa
709 709 new file mode 100644
710 710 --- /dev/null
711 711 +++ b/aaa
712 712 @@ -0,0 +1,3 @@
713 713 +a
714 714 +a
715 715 +aa
716 716 diff --git a/x b/x
717 717 new file mode 100644
718 718 --- /dev/null
719 719 +++ b/x
720 720 @@ -0,0 +1,1 @@
721 721 +x
722 722
723 723 $ hg debugrename aaa
724 724 aaa renamed from aa:37d9b5d994eab34eda9c16b195ace52c7b129980
725 725 $ hg mv aaa aa
726 726 $ hg ci --amend -m 'merge bar again (undo rename)'
727 727 $ hg log --config diff.git=1 -pr .
728 728 changeset: 30:522688c0e71b
729 729 tag: tip
730 730 parent: 26:7fb89c461f81
731 731 parent: 27:4c94d5bc65f5
732 732 user: test
733 733 date: Thu Jan 01 00:00:00 1970 +0000
734 734 summary: merge bar again (undo rename)
735 735
736 736 diff --git a/aa b/aa
737 737 --- a/aa
738 738 +++ b/aa
739 739 @@ -1,2 +1,3 @@
740 740 a
741 741 a
742 742 +aa
743 743 diff --git a/x b/x
744 744 new file mode 100644
745 745 --- /dev/null
746 746 +++ b/x
747 747 @@ -0,0 +1,1 @@
748 748 +x
749 749
750 750 $ hg debugrename aa
751 751 aa not renamed
752 752 $ hg debugrename -r '.^' aa
753 753 aa renamed from a:a80d06849b333b8a3d5c445f8ba3142010dcdc9e
754 754
755 755 Amend a merge changeset (with manifest-level conflicts):
756 756
757 757 $ hg up -q bar
758 758 $ hg rm aa
759 759 $ hg ci -m 'rm aa'
760 760 $ hg up -q default
761 761 $ echo aa >> aa
762 762 $ hg ci -m aa
763 763 $ hg merge -q bar
764 764 local changed aa which remote deleted
765 765 use (c)hanged version or (d)elete? c
766 766 $ hg ci -m 'merge bar (with conflicts)'
767 767 $ hg log --config diff.git=1 -pr .
768 768 changeset: 33:5f9904c491b8
769 769 tag: tip
770 770 parent: 32:01780b896f58
771 771 parent: 31:67db8847a540
772 772 user: test
773 773 date: Thu Jan 01 00:00:00 1970 +0000
774 774 summary: merge bar (with conflicts)
775 775
776 776
777 777 $ hg rm aa
778 778 $ hg ci --amend -m 'merge bar (with conflicts, amended)'
779 779 $ hg log --config diff.git=1 -pr .
780 780 changeset: 35:6ce0c89781a3
781 781 tag: tip
782 782 parent: 32:01780b896f58
783 783 parent: 31:67db8847a540
784 784 user: test
785 785 date: Thu Jan 01 00:00:00 1970 +0000
786 786 summary: merge bar (with conflicts, amended)
787 787
788 788 diff --git a/aa b/aa
789 789 deleted file mode 100644
790 790 --- a/aa
791 791 +++ /dev/null
792 792 @@ -1,4 +0,0 @@
793 793 -a
794 794 -a
795 795 -aa
796 796 -aa
797 797
798 798 Issue 3445: amending with --close-branch a commit that created a new head should fail
799 799 This shouldn't be possible:
800 800
801 801 $ hg up -q default
802 802 $ hg branch closewithamend
803 803 marked working directory as branch closewithamend
804 804 (branches are permanent and global, did you want a bookmark?)
805 805 $ hg add obs.py
806 806 $ hg ci -m..
807 807 $ hg ci --amend --close-branch -m 'closing'
808 808 abort: can only close branch heads
809 809 [255]
810 810
811 811 This silliness fails:
812 812
813 813 $ hg branch silliness
814 814 marked working directory as branch silliness
815 815 (branches are permanent and global, did you want a bookmark?)
816 816 $ echo b >> b
817 817 $ hg ci --close-branch -m'open and close'
818 818 abort: can only close branch heads
819 819 [255]
820 820
821 821 Test that amend with --secret creates new secret changeset forcibly
822 822 ---------------------------------------------------------------------
823 823
824 824 $ hg phase '.^::.'
825 825 35: draft
826 826 36: draft
827 827 $ hg commit --amend --secret -m 'amend as secret' -q
828 828 $ hg phase '.^::.'
829 829 35: draft
830 830 38: secret
831 831
832 832 Test that amend with --edit invokes editor forcibly
833 833 ---------------------------------------------------
834 834
835 835 $ hg parents --template "{desc}\n"
836 836 amend as secret
837 837 $ HGEDITOR=cat hg commit --amend -m "editor should be suppressed"
838 838 $ hg parents --template "{desc}\n"
839 839 editor should be suppressed
840 840
841 841 $ HGEDITOR=cat hg commit --amend -m "editor should be invoked" --edit
842 842 editor should be invoked
843 843
844 844
845 845 HG: Enter commit message. Lines beginning with 'HG:' are removed.
846 846 HG: Leave message empty to abort commit.
847 847 HG: --
848 848 HG: user: test
849 849 HG: branch 'silliness'
850 850 HG: changed obs.py
851 851 $ hg parents --template "{desc}\n"
852 852 editor should be invoked
@@ -1,47 +1,47 b''
1 1 $ addcommit () {
2 2 > echo $1 > $1
3 3 > hg add $1
4 4 > hg commit -d "${2} 0" -m $1
5 5 > }
6 6
7 7 $ commit () {
8 8 > hg commit -d "${2} 0" -m $1
9 9 > }
10 10
11 11 $ hg init a
12 12 $ cd a
13 13 $ addcommit "A" 0
14 14 $ addcommit "B" 1
15 15 $ echo "C" >> A
16 16 $ commit "C" 2
17 17
18 18 $ hg update -C 0
19 19 1 files updated, 0 files merged, 1 files removed, 0 files unresolved
20 20 $ echo "D" >> A
21 21 $ commit "D" 3
22 22 created new head
23 23
24 24 Merging a conflict araises
25 25
26 26 $ hg merge
27 27 merging A
28 28 warning: conflicts during merge.
29 29 merging A incomplete! (edit conflicts, then use 'hg resolve --mark')
30 30 1 files updated, 0 files merged, 0 files removed, 1 files unresolved
31 31 use 'hg resolve' to retry unresolved file merges or 'hg update -C .' to abandon
32 32 [1]
33 33
34 34 Correct the conflict without marking the file as resolved
35 35
36 36 $ echo "ABCD" > A
37 37 $ hg commit -m "Merged"
38 38 abort: unresolved merge conflicts (see hg help resolve)
39 39 [255]
40 40
41 41 Mark the conflict as resolved and commit
42 42
43 43 $ hg resolve -m A
44 no unresolved files; you may continue your unfinished operation
44 no more unresolved files
45 45 $ hg commit -m "Merged"
46 46
47 47 $ cd ..
@@ -1,432 +1,432 b''
1 1 $ "$TESTDIR/hghave" svn13 || exit 80
2 2
3 3 $ svnupanddisplay()
4 4 > {
5 5 > (
6 6 > cd $1;
7 7 > svn up -q;
8 8 > svn st -v | sed 's/ */ /g' | sort
9 9 > limit=''
10 10 > if [ $2 -gt 0 ]; then
11 11 > limit="--limit=$2"
12 12 > fi
13 13 > svn log --xml -v $limit | python "$TESTDIR/svnxml.py"
14 14 > )
15 15 > }
16 16
17 17 $ cat >> $HGRCPATH <<EOF
18 18 > [extensions]
19 19 > convert =
20 20 > EOF
21 21
22 22 $ hg init a
23 23
24 24 Add
25 25
26 26 $ echo a > a/a
27 27 $ mkdir -p a/d1/d2
28 28 $ echo b > a/d1/d2/b
29 29 $ hg --cwd a ci -d '0 0' -A -m 'add a file'
30 30 adding a
31 31 adding d1/d2/b
32 32
33 33 Modify
34 34
35 35 $ "$TESTDIR/svn-safe-append.py" a a/a
36 36 $ hg --cwd a ci -d '1 0' -m 'modify a file'
37 37 $ hg --cwd a tip -q
38 38 1:e0e2b8a9156b
39 39
40 40 $ hg convert -d svn a
41 41 assuming destination a-hg
42 42 initializing svn repository 'a-hg'
43 43 initializing svn working copy 'a-hg-wc'
44 44 scanning source...
45 45 sorting...
46 46 converting...
47 47 1 add a file
48 48 0 modify a file
49 49 $ svnupanddisplay a-hg-wc 2
50 50 2 1 test d1
51 51 2 1 test d1/d2 (glob)
52 52 2 1 test d1/d2/b (glob)
53 53 2 2 test .
54 54 2 2 test a
55 55 revision: 2
56 56 author: test
57 57 msg: modify a file
58 58 M /a
59 59 revision: 1
60 60 author: test
61 61 msg: add a file
62 62 A /a
63 63 A /d1
64 64 A /d1/d2
65 65 A /d1/d2/b
66 66 $ ls a a-hg-wc
67 67 a:
68 68 a
69 69 d1
70 70
71 71 a-hg-wc:
72 72 a
73 73 d1
74 74 $ cmp a/a a-hg-wc/a
75 75
76 76 Rename
77 77
78 78 $ hg --cwd a mv a b
79 79 $ hg --cwd a ci -d '2 0' -m 'rename a file'
80 80 $ hg --cwd a tip -q
81 81 2:eb5169441d43
82 82
83 83 $ hg convert -d svn a
84 84 assuming destination a-hg
85 85 initializing svn working copy 'a-hg-wc'
86 86 scanning source...
87 87 sorting...
88 88 converting...
89 89 0 rename a file
90 90 $ svnupanddisplay a-hg-wc 1
91 91 3 1 test d1
92 92 3 1 test d1/d2 (glob)
93 93 3 1 test d1/d2/b (glob)
94 94 3 3 test .
95 95 3 3 test b
96 96 revision: 3
97 97 author: test
98 98 msg: rename a file
99 99 D /a
100 100 A /b (from /a@2)
101 101 $ ls a a-hg-wc
102 102 a:
103 103 b
104 104 d1
105 105
106 106 a-hg-wc:
107 107 b
108 108 d1
109 109
110 110 Copy
111 111
112 112 $ hg --cwd a cp b c
113 113
114 114 $ hg --cwd a ci -d '3 0' -m 'copy a file'
115 115 $ hg --cwd a tip -q
116 116 3:60effef6ab48
117 117
118 118 $ hg convert -d svn a
119 119 assuming destination a-hg
120 120 initializing svn working copy 'a-hg-wc'
121 121 scanning source...
122 122 sorting...
123 123 converting...
124 124 0 copy a file
125 125 $ svnupanddisplay a-hg-wc 1
126 126 4 1 test d1
127 127 4 1 test d1/d2 (glob)
128 128 4 1 test d1/d2/b (glob)
129 129 4 3 test b
130 130 4 4 test .
131 131 4 4 test c
132 132 revision: 4
133 133 author: test
134 134 msg: copy a file
135 135 A /c (from /b@3)
136 136 $ ls a a-hg-wc
137 137 a:
138 138 b
139 139 c
140 140 d1
141 141
142 142 a-hg-wc:
143 143 b
144 144 c
145 145 d1
146 146
147 147 $ hg --cwd a rm b
148 148
149 149 Remove
150 150
151 151 $ hg --cwd a ci -d '4 0' -m 'remove a file'
152 152 $ hg --cwd a tip -q
153 153 4:87bbe3013fb6
154 154
155 155 $ hg convert -d svn a
156 156 assuming destination a-hg
157 157 initializing svn working copy 'a-hg-wc'
158 158 scanning source...
159 159 sorting...
160 160 converting...
161 161 0 remove a file
162 162 $ svnupanddisplay a-hg-wc 1
163 163 5 1 test d1
164 164 5 1 test d1/d2 (glob)
165 165 5 1 test d1/d2/b (glob)
166 166 5 4 test c
167 167 5 5 test .
168 168 revision: 5
169 169 author: test
170 170 msg: remove a file
171 171 D /b
172 172 $ ls a a-hg-wc
173 173 a:
174 174 c
175 175 d1
176 176
177 177 a-hg-wc:
178 178 c
179 179 d1
180 180
181 181 Executable
182 182
183 183 #if execbit
184 184 $ chmod +x a/c
185 185 #else
186 186 $ echo fake >> a/c
187 187 #endif
188 188 $ hg --cwd a ci -d '5 0' -m 'make a file executable'
189 189 #if execbit
190 190 $ hg --cwd a tip -q
191 191 5:ff42e473c340
192 192 #else
193 193 $ hg --cwd a tip -q
194 194 5:817a700c8cf1
195 195 #endif
196 196
197 197 $ hg convert -d svn a
198 198 assuming destination a-hg
199 199 initializing svn working copy 'a-hg-wc'
200 200 scanning source...
201 201 sorting...
202 202 converting...
203 203 0 make a file executable
204 204 $ svnupanddisplay a-hg-wc 1
205 205 6 1 test d1
206 206 6 1 test d1/d2 (glob)
207 207 6 1 test d1/d2/b (glob)
208 208 6 6 test .
209 209 6 6 test c
210 210 revision: 6
211 211 author: test
212 212 msg: make a file executable
213 213 M /c
214 214 #if execbit
215 215 $ test -x a-hg-wc/c
216 216 #endif
217 217
218 218 #if symlink
219 219
220 220 Symlinks
221 221
222 222 $ ln -s a/missing a/link
223 223 $ hg --cwd a commit -Am 'add symlink'
224 224 adding link
225 225 $ hg --cwd a mv link newlink
226 226 $ hg --cwd a commit -m 'move symlink'
227 227 $ hg convert -d svn a
228 228 assuming destination a-hg
229 229 initializing svn working copy 'a-hg-wc'
230 230 scanning source...
231 231 sorting...
232 232 converting...
233 233 1 add symlink
234 234 0 move symlink
235 235 $ svnupanddisplay a-hg-wc 1
236 236 8 1 test d1
237 237 8 1 test d1/d2
238 238 8 1 test d1/d2/b
239 239 8 6 test c
240 240 8 8 test .
241 241 8 8 test newlink
242 242 revision: 8
243 243 author: test
244 244 msg: move symlink
245 245 D /link
246 246 A /newlink (from /link@7)
247 247
248 248 #endif
249 249
250 250 $ rm -rf a a-hg a-hg-wc
251 251
252 252
253 253 Executable in new directory
254 254
255 255 $ hg init a
256 256
257 257 $ mkdir a/d1
258 258 $ echo a > a/d1/a
259 259 #if execbit
260 260 $ chmod +x a/d1/a
261 261 #else
262 262 $ echo fake >> a/d1/a
263 263 #endif
264 264 $ hg --cwd a ci -d '0 0' -A -m 'add executable file in new directory'
265 265 adding d1/a
266 266
267 267 $ hg convert -d svn a
268 268 assuming destination a-hg
269 269 initializing svn repository 'a-hg'
270 270 initializing svn working copy 'a-hg-wc'
271 271 scanning source...
272 272 sorting...
273 273 converting...
274 274 0 add executable file in new directory
275 275 $ svnupanddisplay a-hg-wc 1
276 276 1 1 test .
277 277 1 1 test d1
278 278 1 1 test d1/a (glob)
279 279 revision: 1
280 280 author: test
281 281 msg: add executable file in new directory
282 282 A /d1
283 283 A /d1/a
284 284 #if execbit
285 285 $ test -x a-hg-wc/d1/a
286 286 #endif
287 287
288 288 Copy to new directory
289 289
290 290 $ mkdir a/d2
291 291 $ hg --cwd a cp d1/a d2/a
292 292 $ hg --cwd a ci -d '1 0' -A -m 'copy file to new directory'
293 293
294 294 $ hg convert -d svn a
295 295 assuming destination a-hg
296 296 initializing svn working copy 'a-hg-wc'
297 297 scanning source...
298 298 sorting...
299 299 converting...
300 300 0 copy file to new directory
301 301 $ svnupanddisplay a-hg-wc 1
302 302 2 1 test d1
303 303 2 1 test d1/a (glob)
304 304 2 2 test .
305 305 2 2 test d2
306 306 2 2 test d2/a (glob)
307 307 revision: 2
308 308 author: test
309 309 msg: copy file to new directory
310 310 A /d2
311 311 A /d2/a (from /d1/a@1)
312 312
313 313 Branchy history
314 314
315 315 $ hg init b
316 316 $ echo base > b/b
317 317 $ hg --cwd b ci -d '0 0' -Ambase
318 318 adding b
319 319
320 320 $ "$TESTDIR/svn-safe-append.py" left-1 b/b
321 321 $ echo left-1 > b/left-1
322 322 $ hg --cwd b ci -d '1 0' -Amleft-1
323 323 adding left-1
324 324
325 325 $ "$TESTDIR/svn-safe-append.py" left-2 b/b
326 326 $ echo left-2 > b/left-2
327 327 $ hg --cwd b ci -d '2 0' -Amleft-2
328 328 adding left-2
329 329
330 330 $ hg --cwd b up 0
331 331 1 files updated, 0 files merged, 2 files removed, 0 files unresolved
332 332
333 333 $ "$TESTDIR/svn-safe-append.py" right-1 b/b
334 334 $ echo right-1 > b/right-1
335 335 $ hg --cwd b ci -d '3 0' -Amright-1
336 336 adding right-1
337 337 created new head
338 338
339 339 $ "$TESTDIR/svn-safe-append.py" right-2 b/b
340 340 $ echo right-2 > b/right-2
341 341 $ hg --cwd b ci -d '4 0' -Amright-2
342 342 adding right-2
343 343
344 344 $ hg --cwd b up -C 2
345 345 3 files updated, 0 files merged, 2 files removed, 0 files unresolved
346 346 $ hg --cwd b merge
347 347 merging b
348 348 warning: conflicts during merge.
349 349 merging b incomplete! (edit conflicts, then use 'hg resolve --mark')
350 350 2 files updated, 0 files merged, 0 files removed, 1 files unresolved
351 351 use 'hg resolve' to retry unresolved file merges or 'hg update -C .' to abandon
352 352 [1]
353 353 $ hg --cwd b revert -r 2 b
354 354 $ hg --cwd b resolve -m b
355 no unresolved files; you may continue your unfinished operation
355 no more unresolved files
356 356 $ hg --cwd b ci -d '5 0' -m 'merge'
357 357
358 358 Expect 4 changes
359 359
360 360 $ hg convert -d svn b
361 361 assuming destination b-hg
362 362 initializing svn repository 'b-hg'
363 363 initializing svn working copy 'b-hg-wc'
364 364 scanning source...
365 365 sorting...
366 366 converting...
367 367 5 base
368 368 4 left-1
369 369 3 left-2
370 370 2 right-1
371 371 1 right-2
372 372 0 merge
373 373
374 374 $ svnupanddisplay b-hg-wc 0
375 375 4 2 test left-1
376 376 4 3 test b
377 377 4 3 test left-2
378 378 4 4 test .
379 379 4 4 test right-1
380 380 4 4 test right-2
381 381 revision: 4
382 382 author: test
383 383 msg: merge
384 384 A /right-1
385 385 A /right-2
386 386 revision: 3
387 387 author: test
388 388 msg: left-2
389 389 M /b
390 390 A /left-2
391 391 revision: 2
392 392 author: test
393 393 msg: left-1
394 394 M /b
395 395 A /left-1
396 396 revision: 1
397 397 author: test
398 398 msg: base
399 399 A /b
400 400
401 401 Tags are not supported, but must not break conversion
402 402
403 403 $ rm -rf a a-hg a-hg-wc
404 404 $ hg init a
405 405 $ echo a > a/a
406 406 $ hg --cwd a ci -d '0 0' -A -m 'Add file a'
407 407 adding a
408 408 $ hg --cwd a tag -d '1 0' -m 'Tagged as v1.0' v1.0
409 409
410 410 $ hg convert -d svn a
411 411 assuming destination a-hg
412 412 initializing svn repository 'a-hg'
413 413 initializing svn working copy 'a-hg-wc'
414 414 scanning source...
415 415 sorting...
416 416 converting...
417 417 1 Add file a
418 418 0 Tagged as v1.0
419 419 writing Subversion tags is not yet implemented
420 420 $ svnupanddisplay a-hg-wc 2
421 421 2 1 test a
422 422 2 2 test .
423 423 2 2 test .hgtags
424 424 revision: 2
425 425 author: test
426 426 msg: Tagged as v1.0
427 427 A /.hgtags
428 428 revision: 1
429 429 author: test
430 430 msg: Add file a
431 431 A /a
432 432 $ rm -rf a a-hg a-hg-wc
@@ -1,248 +1,248 b''
1 1 $ fileset() {
2 2 > hg debugfileset "$@"
3 3 > }
4 4
5 5 $ hg init repo
6 6 $ cd repo
7 7 $ echo a > a1
8 8 $ echo a > a2
9 9 $ echo b > b1
10 10 $ echo b > b2
11 11 $ hg ci -Am addfiles
12 12 adding a1
13 13 adding a2
14 14 adding b1
15 15 adding b2
16 16
17 17 Test operators and basic patterns
18 18
19 19 $ fileset a1
20 20 a1
21 21 $ fileset 'a*'
22 22 a1
23 23 a2
24 24 $ fileset '"re:a\d"'
25 25 a1
26 26 a2
27 27 $ fileset 'a1 or a2'
28 28 a1
29 29 a2
30 30 $ fileset 'a1 | a2'
31 31 a1
32 32 a2
33 33 $ fileset 'a* and "*1"'
34 34 a1
35 35 $ fileset 'a* & "*1"'
36 36 a1
37 37 $ fileset 'not (r"a*")'
38 38 b1
39 39 b2
40 40 $ fileset '! ("a*")'
41 41 b1
42 42 b2
43 43 $ fileset 'a* - a1'
44 44 a2
45 45 $ fileset 'a_b'
46 46
47 47 Test files status
48 48
49 49 $ rm a1
50 50 $ hg rm a2
51 51 $ echo b >> b2
52 52 $ hg cp b1 c1
53 53 $ echo c > c2
54 54 $ echo c > c3
55 55 $ cat > .hgignore <<EOF
56 56 > \.hgignore
57 57 > 2$
58 58 > EOF
59 59 $ fileset 'modified()'
60 60 b2
61 61 $ fileset 'added()'
62 62 c1
63 63 $ fileset 'removed()'
64 64 a2
65 65 $ fileset 'deleted()'
66 66 a1
67 67 $ fileset 'unknown()'
68 68 c3
69 69 $ fileset 'ignored()'
70 70 .hgignore
71 71 c2
72 72 $ fileset 'hgignore()'
73 73 a2
74 74 b2
75 75 $ fileset 'clean()'
76 76 b1
77 77 $ fileset 'copied()'
78 78 c1
79 79
80 80 Test files properties
81 81
82 82 >>> file('bin', 'wb').write('\0a')
83 83 $ fileset 'binary()'
84 84 $ fileset 'binary() and unknown()'
85 85 bin
86 86 $ echo '^bin$' >> .hgignore
87 87 $ fileset 'binary() and ignored()'
88 88 bin
89 89 $ hg add bin
90 90 $ fileset 'binary()'
91 91 bin
92 92
93 93 $ fileset 'grep("b{1}")'
94 94 b2
95 95 c1
96 96 b1
97 97 $ fileset 'grep("missingparens(")'
98 98 hg: parse error: invalid match pattern: unbalanced parenthesis
99 99 [255]
100 100
101 101 #if execbit
102 102 $ chmod +x b2
103 103 $ fileset 'exec()'
104 104 b2
105 105 #endif
106 106
107 107 #if symlink
108 108 $ ln -s b2 b2link
109 109 $ fileset 'symlink() and unknown()'
110 110 b2link
111 111 $ hg add b2link
112 112 #endif
113 113
114 114 >>> file('1k', 'wb').write(' '*1024)
115 115 >>> file('2k', 'wb').write(' '*2048)
116 116 $ hg add 1k 2k
117 117 $ fileset 'size("bar")'
118 118 hg: parse error: couldn't parse size: bar
119 119 [255]
120 120 $ fileset 'size(1k)'
121 121 1k
122 122 $ fileset '(1k or 2k) and size("< 2k")'
123 123 1k
124 124 $ fileset '(1k or 2k) and size("<=2k")'
125 125 1k
126 126 2k
127 127 $ fileset '(1k or 2k) and size("> 1k")'
128 128 2k
129 129 $ fileset '(1k or 2k) and size(">=1K")'
130 130 1k
131 131 2k
132 132 $ fileset '(1k or 2k) and size(".5KB - 1.5kB")'
133 133 1k
134 134
135 135 Test merge states
136 136
137 137 $ hg ci -m manychanges
138 138 $ hg up -C 0
139 139 * files updated, 0 files merged, * files removed, 0 files unresolved (glob)
140 140 $ echo c >> b2
141 141 $ hg ci -m diverging b2
142 142 created new head
143 143 $ fileset 'resolved()'
144 144 $ fileset 'unresolved()'
145 145 $ hg merge
146 146 merging b2
147 147 warning: conflicts during merge.
148 148 merging b2 incomplete! (edit conflicts, then use 'hg resolve --mark')
149 149 * files updated, 0 files merged, * files removed, 1 files unresolved (glob)
150 150 use 'hg resolve' to retry unresolved file merges or 'hg update -C .' to abandon
151 151 [1]
152 152 $ fileset 'resolved()'
153 153 $ fileset 'unresolved()'
154 154 b2
155 155 $ echo e > b2
156 156 $ hg resolve -m b2
157 no unresolved files; you may continue your unfinished operation
157 no more unresolved files
158 158 $ fileset 'resolved()'
159 159 b2
160 160 $ fileset 'unresolved()'
161 161 $ hg ci -m merge
162 162
163 163 Test subrepo predicate
164 164
165 165 $ hg init sub
166 166 $ echo a > sub/suba
167 167 $ hg -R sub add sub/suba
168 168 $ hg -R sub ci -m sub
169 169 $ echo 'sub = sub' > .hgsub
170 170 $ fileset 'subrepo()'
171 171 $ hg add .hgsub
172 172 $ fileset 'subrepo()'
173 173 sub
174 174 $ fileset 'subrepo("sub")'
175 175 sub
176 176 $ fileset 'subrepo("glob:*")'
177 177 sub
178 178 $ hg ci -m subrepo
179 179
180 180 Test with a revision
181 181
182 182 $ hg log -G --template '{rev} {desc}\n'
183 183 @ 4 subrepo
184 184 |
185 185 o 3 merge
186 186 |\
187 187 | o 2 diverging
188 188 | |
189 189 o | 1 manychanges
190 190 |/
191 191 o 0 addfiles
192 192
193 193 $ echo unknown > unknown
194 194 $ fileset -r1 'modified()'
195 195 b2
196 196 $ fileset -r1 'added() and c1'
197 197 c1
198 198 $ fileset -r1 'removed()'
199 199 a2
200 200 $ fileset -r1 'deleted()'
201 201 $ fileset -r1 'unknown()'
202 202 $ fileset -r1 'ignored()'
203 203 $ fileset -r1 'hgignore()'
204 204 b2
205 205 bin
206 206 $ fileset -r1 'binary()'
207 207 bin
208 208 $ fileset -r1 'size(1k)'
209 209 1k
210 210 $ fileset -r3 'resolved()'
211 211 $ fileset -r3 'unresolved()'
212 212
213 213 #if execbit
214 214 $ fileset -r1 'exec()'
215 215 b2
216 216 #endif
217 217
218 218 #if symlink
219 219 $ fileset -r1 'symlink()'
220 220 b2link
221 221 #endif
222 222
223 223 $ fileset -r4 'subrepo("re:su.*")'
224 224 sub
225 225 $ fileset -r4 'subrepo("sub")'
226 226 sub
227 227 $ fileset -r4 'b2 or c1'
228 228 b2
229 229 c1
230 230
231 231 >>> open('dos', 'wb').write("dos\r\n")
232 232 >>> open('mixed', 'wb').write("dos\r\nunix\n")
233 233 >>> open('mac', 'wb').write("mac\r")
234 234 $ hg add dos mixed mac
235 235
236 236 $ fileset 'eol(dos)'
237 237 dos
238 238 mixed
239 239 $ fileset 'eol(unix)'
240 240 .hgsub
241 241 .hgsubstate
242 242 a1
243 243 b1
244 244 b2
245 245 c1
246 246 mixed
247 247 $ fileset 'eol(mac)'
248 248 mac
@@ -1,587 +1,587 b''
1 1 Create a repo with some stuff in it:
2 2
3 3 $ hg init a
4 4 $ cd a
5 5 $ echo a > a
6 6 $ echo a > d
7 7 $ echo a > e
8 8 $ hg ci -qAm0
9 9 $ echo b > a
10 10 $ hg ci -m1 -u bar
11 11 $ hg mv a b
12 12 $ hg ci -m2
13 13 $ hg cp b c
14 14 $ hg ci -m3 -u baz
15 15 $ echo b > d
16 16 $ echo f > e
17 17 $ hg ci -m4
18 18 $ hg up -q 3
19 19 $ echo b > e
20 20 $ hg branch -q stable
21 21 $ hg ci -m5
22 22 $ hg merge -q default --tool internal:local
23 23 $ hg branch -q default
24 24 $ hg ci -m6
25 25 $ hg phase --public 3
26 26 $ hg phase --force --secret 6
27 27
28 28 $ hg log -G --template '{author}@{rev}.{phase}: {desc}\n'
29 29 @ test@6.secret: 6
30 30 |\
31 31 | o test@5.draft: 5
32 32 | |
33 33 o | test@4.draft: 4
34 34 |/
35 35 o baz@3.public: 3
36 36 |
37 37 o test@2.public: 2
38 38 |
39 39 o bar@1.public: 1
40 40 |
41 41 o test@0.public: 0
42 42
43 43
44 44 Need to specify a rev:
45 45
46 46 $ hg graft
47 47 abort: no revisions specified
48 48 [255]
49 49
50 50 Can't graft ancestor:
51 51
52 52 $ hg graft 1 2
53 53 skipping ancestor revision 1
54 54 skipping ancestor revision 2
55 55 [255]
56 56
57 57 Specify revisions with -r:
58 58
59 59 $ hg graft -r 1 -r 2
60 60 skipping ancestor revision 1
61 61 skipping ancestor revision 2
62 62 [255]
63 63
64 64 $ hg graft -r 1 2
65 65 skipping ancestor revision 2
66 66 skipping ancestor revision 1
67 67 [255]
68 68
69 69 Can't graft with dirty wd:
70 70
71 71 $ hg up -q 0
72 72 $ echo foo > a
73 73 $ hg graft 1
74 74 abort: uncommitted changes
75 75 [255]
76 76 $ hg revert a
77 77
78 78 Graft a rename:
79 79
80 80 $ hg graft 2 -u foo
81 81 grafting revision 2
82 82 merging a and b to b
83 83 $ hg export tip --git
84 84 # HG changeset patch
85 85 # User foo
86 86 # Date 0 0
87 87 # Thu Jan 01 00:00:00 1970 +0000
88 88 # Node ID ef0ef43d49e79e81ddafdc7997401ba0041efc82
89 89 # Parent 68795b066622ca79a25816a662041d8f78f3cd9e
90 90 2
91 91
92 92 diff --git a/a b/b
93 93 rename from a
94 94 rename to b
95 95
96 96 Look for extra:source
97 97
98 98 $ hg log --debug -r tip
99 99 changeset: 7:ef0ef43d49e79e81ddafdc7997401ba0041efc82
100 100 tag: tip
101 101 phase: draft
102 102 parent: 0:68795b066622ca79a25816a662041d8f78f3cd9e
103 103 parent: -1:0000000000000000000000000000000000000000
104 104 manifest: 7:e59b6b228f9cbf9903d5e9abf996e083a1f533eb
105 105 user: foo
106 106 date: Thu Jan 01 00:00:00 1970 +0000
107 107 files+: b
108 108 files-: a
109 109 extra: branch=default
110 110 extra: source=5c095ad7e90f871700f02dd1fa5012cb4498a2d4
111 111 description:
112 112 2
113 113
114 114
115 115
116 116 Graft out of order, skipping a merge and a duplicate
117 117
118 118 $ hg graft 1 5 4 3 'merge()' 2 -n
119 119 skipping ungraftable merge revision 6
120 120 skipping revision 2 (already grafted to 7)
121 121 grafting revision 1
122 122 grafting revision 5
123 123 grafting revision 4
124 124 grafting revision 3
125 125
126 126 $ hg graft 1 5 4 3 'merge()' 2 --debug
127 127 skipping ungraftable merge revision 6
128 128 scanning for duplicate grafts
129 129 skipping revision 2 (already grafted to 7)
130 130 grafting revision 1
131 131 searching for copies back to rev 1
132 132 unmatched files in local:
133 133 b
134 134 all copies found (* = to merge, ! = divergent, % = renamed and deleted):
135 135 src: 'a' -> dst: 'b' *
136 136 checking for directory renames
137 137 resolving manifests
138 138 branchmerge: True, force: True, partial: False
139 139 ancestor: 68795b066622, local: ef0ef43d49e7+, remote: 5d205f8b35b6
140 140 b: local copied/moved from a -> m
141 141 preserving b for resolve of b
142 142 updating: b 1/1 files (100.00%)
143 143 picked tool 'internal:merge' for b (binary False symlink False)
144 144 merging b and a to b
145 145 my b@ef0ef43d49e7+ other a@5d205f8b35b6 ancestor a@68795b066622
146 146 premerge successful
147 147 b
148 148 grafting revision 5
149 149 searching for copies back to rev 1
150 150 resolving manifests
151 151 branchmerge: True, force: True, partial: False
152 152 ancestor: 4c60f11aa304, local: 6b9e5368ca4e+, remote: 97f8bfe72746
153 153 b: keep -> k
154 154 e: remote is newer -> g
155 155 getting e
156 156 updating: e 1/1 files (100.00%)
157 157 e
158 158 grafting revision 4
159 159 searching for copies back to rev 1
160 160 resolving manifests
161 161 branchmerge: True, force: True, partial: False
162 162 ancestor: 4c60f11aa304, local: 1905859650ec+, remote: 9c233e8e184d
163 163 b: keep -> k
164 164 d: remote is newer -> g
165 165 e: versions differ -> m
166 166 preserving e for resolve of e
167 167 getting d
168 168 updating: d 1/2 files (50.00%)
169 169 updating: e 2/2 files (100.00%)
170 170 picked tool 'internal:merge' for e (binary False symlink False)
171 171 merging e
172 172 my e@1905859650ec+ other e@9c233e8e184d ancestor e@68795b066622
173 173 warning: conflicts during merge.
174 174 merging e incomplete! (edit conflicts, then use 'hg resolve --mark')
175 175 abort: unresolved conflicts, can't continue
176 176 (use hg resolve and hg graft --continue)
177 177 [255]
178 178
179 179 Commit while interrupted should fail:
180 180
181 181 $ hg ci -m 'commit interrupted graft'
182 182 abort: graft in progress
183 183 (use 'hg graft --continue' or 'hg update' to abort)
184 184 [255]
185 185
186 186 Abort the graft and try committing:
187 187
188 188 $ hg up -C .
189 189 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
190 190 $ echo c >> e
191 191 $ hg ci -mtest
192 192
193 193 $ hg strip . --config extensions.mq=
194 194 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
195 195 saved backup bundle to $TESTTMP/a/.hg/strip-backup/*-backup.hg (glob)
196 196
197 197 Graft again:
198 198
199 199 $ hg graft 1 5 4 3 'merge()' 2
200 200 skipping ungraftable merge revision 6
201 201 skipping revision 2 (already grafted to 7)
202 202 skipping revision 1 (already grafted to 8)
203 203 skipping revision 5 (already grafted to 9)
204 204 grafting revision 4
205 205 merging e
206 206 warning: conflicts during merge.
207 207 merging e incomplete! (edit conflicts, then use 'hg resolve --mark')
208 208 abort: unresolved conflicts, can't continue
209 209 (use hg resolve and hg graft --continue)
210 210 [255]
211 211
212 212 Continue without resolve should fail:
213 213
214 214 $ hg graft -c
215 215 grafting revision 4
216 216 abort: unresolved merge conflicts (see hg help resolve)
217 217 [255]
218 218
219 219 Fix up:
220 220
221 221 $ echo b > e
222 222 $ hg resolve -m e
223 no unresolved files; you may continue your unfinished operation
223 no more unresolved files
224 224
225 225 Continue with a revision should fail:
226 226
227 227 $ hg graft -c 6
228 228 abort: can't specify --continue and revisions
229 229 [255]
230 230
231 231 $ hg graft -c -r 6
232 232 abort: can't specify --continue and revisions
233 233 [255]
234 234
235 235 Continue for real, clobber usernames
236 236
237 237 $ hg graft -c -U
238 238 grafting revision 4
239 239 grafting revision 3
240 240
241 241 Compare with original:
242 242
243 243 $ hg diff -r 6
244 244 $ hg status --rev 0:. -C
245 245 M d
246 246 M e
247 247 A b
248 248 a
249 249 A c
250 250 a
251 251 R a
252 252
253 253 View graph:
254 254
255 255 $ hg log -G --template '{author}@{rev}.{phase}: {desc}\n'
256 256 @ test@11.draft: 3
257 257 |
258 258 o test@10.draft: 4
259 259 |
260 260 o test@9.draft: 5
261 261 |
262 262 o bar@8.draft: 1
263 263 |
264 264 o foo@7.draft: 2
265 265 |
266 266 | o test@6.secret: 6
267 267 | |\
268 268 | | o test@5.draft: 5
269 269 | | |
270 270 | o | test@4.draft: 4
271 271 | |/
272 272 | o baz@3.public: 3
273 273 | |
274 274 | o test@2.public: 2
275 275 | |
276 276 | o bar@1.public: 1
277 277 |/
278 278 o test@0.public: 0
279 279
280 280 Graft again onto another branch should preserve the original source
281 281 $ hg up -q 0
282 282 $ echo 'g'>g
283 283 $ hg add g
284 284 $ hg ci -m 7
285 285 created new head
286 286 $ hg graft 7
287 287 grafting revision 7
288 288
289 289 $ hg log -r 7 --template '{rev}:{node}\n'
290 290 7:ef0ef43d49e79e81ddafdc7997401ba0041efc82
291 291 $ hg log -r 2 --template '{rev}:{node}\n'
292 292 2:5c095ad7e90f871700f02dd1fa5012cb4498a2d4
293 293
294 294 $ hg log --debug -r tip
295 295 changeset: 13:9db0f28fd3747e92c57d015f53b5593aeec53c2d
296 296 tag: tip
297 297 phase: draft
298 298 parent: 12:b592ea63bb0c19a6c5c44685ee29a2284f9f1b8f
299 299 parent: -1:0000000000000000000000000000000000000000
300 300 manifest: 13:dc313617b8c32457c0d589e0dbbedfe71f3cd637
301 301 user: foo
302 302 date: Thu Jan 01 00:00:00 1970 +0000
303 303 files+: b
304 304 files-: a
305 305 extra: branch=default
306 306 extra: source=5c095ad7e90f871700f02dd1fa5012cb4498a2d4
307 307 description:
308 308 2
309 309
310 310
311 311 Disallow grafting an already grafted cset onto its original branch
312 312 $ hg up -q 6
313 313 $ hg graft 7
314 314 skipping already grafted revision 7 (was grafted from 2)
315 315 [255]
316 316
317 317 Disallow grafting already grafted csets with the same origin onto each other
318 318 $ hg up -q 13
319 319 $ hg graft 2
320 320 skipping revision 2 (already grafted to 13)
321 321 [255]
322 322 $ hg graft 7
323 323 skipping already grafted revision 7 (13 also has origin 2)
324 324 [255]
325 325
326 326 $ hg up -q 7
327 327 $ hg graft 2
328 328 skipping revision 2 (already grafted to 7)
329 329 [255]
330 330 $ hg graft tip
331 331 skipping already grafted revision 13 (7 also has origin 2)
332 332 [255]
333 333
334 334 Graft with --log
335 335
336 336 $ hg up -Cq 1
337 337 $ hg graft 3 --log -u foo
338 338 grafting revision 3
339 339 warning: can't find ancestor for 'c' copied from 'b'!
340 340 $ hg log --template '{rev} {parents} {desc}\n' -r tip
341 341 14 1:5d205f8b35b6 3
342 342 (grafted from 4c60f11aa304a54ae1c199feb94e7fc771e51ed8)
343 343
344 344 Resolve conflicted graft
345 345 $ hg up -q 0
346 346 $ echo b > a
347 347 $ hg ci -m 8
348 348 created new head
349 349 $ echo a > a
350 350 $ hg ci -m 9
351 351 $ hg graft 1 --tool internal:fail
352 352 grafting revision 1
353 353 abort: unresolved conflicts, can't continue
354 354 (use hg resolve and hg graft --continue)
355 355 [255]
356 356 $ hg resolve --all
357 357 merging a
358 no unresolved files; you may continue your unfinished operation
358 no more unresolved files
359 359 $ hg graft -c
360 360 grafting revision 1
361 361 $ hg export tip --git
362 362 # HG changeset patch
363 363 # User bar
364 364 # Date 0 0
365 365 # Thu Jan 01 00:00:00 1970 +0000
366 366 # Node ID 64ecd9071ce83c6e62f538d8ce7709d53f32ebf7
367 367 # Parent 4bdb9a9d0b84ffee1d30f0dfc7744cade17aa19c
368 368 1
369 369
370 370 diff --git a/a b/a
371 371 --- a/a
372 372 +++ b/a
373 373 @@ -1,1 +1,1 @@
374 374 -a
375 375 +b
376 376
377 377 Resolve conflicted graft with rename
378 378 $ echo c > a
379 379 $ hg ci -m 10
380 380 $ hg graft 2 --tool internal:fail
381 381 grafting revision 2
382 382 abort: unresolved conflicts, can't continue
383 383 (use hg resolve and hg graft --continue)
384 384 [255]
385 385 $ hg resolve --all
386 386 merging a and b to b
387 no unresolved files; you may continue your unfinished operation
387 no more unresolved files
388 388 $ hg graft -c
389 389 grafting revision 2
390 390 $ hg export tip --git
391 391 # HG changeset patch
392 392 # User test
393 393 # Date 0 0
394 394 # Thu Jan 01 00:00:00 1970 +0000
395 395 # Node ID 2e80e1351d6ed50302fe1e05f8bd1d4d412b6e11
396 396 # Parent e5a51ae854a8bbaaf25cc5c6a57ff46042dadbb4
397 397 2
398 398
399 399 diff --git a/a b/b
400 400 rename from a
401 401 rename to b
402 402
403 403 Test simple origin(), with and without args
404 404 $ hg log -r 'origin()'
405 405 changeset: 1:5d205f8b35b6
406 406 user: bar
407 407 date: Thu Jan 01 00:00:00 1970 +0000
408 408 summary: 1
409 409
410 410 changeset: 2:5c095ad7e90f
411 411 user: test
412 412 date: Thu Jan 01 00:00:00 1970 +0000
413 413 summary: 2
414 414
415 415 changeset: 3:4c60f11aa304
416 416 user: baz
417 417 date: Thu Jan 01 00:00:00 1970 +0000
418 418 summary: 3
419 419
420 420 changeset: 4:9c233e8e184d
421 421 user: test
422 422 date: Thu Jan 01 00:00:00 1970 +0000
423 423 summary: 4
424 424
425 425 changeset: 5:97f8bfe72746
426 426 branch: stable
427 427 parent: 3:4c60f11aa304
428 428 user: test
429 429 date: Thu Jan 01 00:00:00 1970 +0000
430 430 summary: 5
431 431
432 432 $ hg log -r 'origin(7)'
433 433 changeset: 2:5c095ad7e90f
434 434 user: test
435 435 date: Thu Jan 01 00:00:00 1970 +0000
436 436 summary: 2
437 437
438 438 Now transplant a graft to test following through copies
439 439 $ hg up -q 0
440 440 $ hg branch -q dev
441 441 $ hg ci -qm "dev branch"
442 442 $ hg --config extensions.transplant= transplant -q 7
443 443 $ hg log -r 'origin(.)'
444 444 changeset: 2:5c095ad7e90f
445 445 user: test
446 446 date: Thu Jan 01 00:00:00 1970 +0000
447 447 summary: 2
448 448
449 449 Test simple destination
450 450 $ hg log -r 'destination()'
451 451 changeset: 7:ef0ef43d49e7
452 452 parent: 0:68795b066622
453 453 user: foo
454 454 date: Thu Jan 01 00:00:00 1970 +0000
455 455 summary: 2
456 456
457 457 changeset: 8:6b9e5368ca4e
458 458 user: bar
459 459 date: Thu Jan 01 00:00:00 1970 +0000
460 460 summary: 1
461 461
462 462 changeset: 9:1905859650ec
463 463 user: test
464 464 date: Thu Jan 01 00:00:00 1970 +0000
465 465 summary: 5
466 466
467 467 changeset: 10:52dc0b4c6907
468 468 user: test
469 469 date: Thu Jan 01 00:00:00 1970 +0000
470 470 summary: 4
471 471
472 472 changeset: 11:882b35362a6b
473 473 user: test
474 474 date: Thu Jan 01 00:00:00 1970 +0000
475 475 summary: 3
476 476
477 477 changeset: 13:9db0f28fd374
478 478 user: foo
479 479 date: Thu Jan 01 00:00:00 1970 +0000
480 480 summary: 2
481 481
482 482 changeset: 14:f64defefacee
483 483 parent: 1:5d205f8b35b6
484 484 user: foo
485 485 date: Thu Jan 01 00:00:00 1970 +0000
486 486 summary: 3
487 487
488 488 changeset: 17:64ecd9071ce8
489 489 user: bar
490 490 date: Thu Jan 01 00:00:00 1970 +0000
491 491 summary: 1
492 492
493 493 changeset: 19:2e80e1351d6e
494 494 user: test
495 495 date: Thu Jan 01 00:00:00 1970 +0000
496 496 summary: 2
497 497
498 498 changeset: 21:7e61b508e709
499 499 branch: dev
500 500 tag: tip
501 501 user: foo
502 502 date: Thu Jan 01 00:00:00 1970 +0000
503 503 summary: 2
504 504
505 505 $ hg log -r 'destination(2)'
506 506 changeset: 7:ef0ef43d49e7
507 507 parent: 0:68795b066622
508 508 user: foo
509 509 date: Thu Jan 01 00:00:00 1970 +0000
510 510 summary: 2
511 511
512 512 changeset: 13:9db0f28fd374
513 513 user: foo
514 514 date: Thu Jan 01 00:00:00 1970 +0000
515 515 summary: 2
516 516
517 517 changeset: 19:2e80e1351d6e
518 518 user: test
519 519 date: Thu Jan 01 00:00:00 1970 +0000
520 520 summary: 2
521 521
522 522 changeset: 21:7e61b508e709
523 523 branch: dev
524 524 tag: tip
525 525 user: foo
526 526 date: Thu Jan 01 00:00:00 1970 +0000
527 527 summary: 2
528 528
529 529 Transplants of grafts can find a destination...
530 530 $ hg log -r 'destination(7)'
531 531 changeset: 21:7e61b508e709
532 532 branch: dev
533 533 tag: tip
534 534 user: foo
535 535 date: Thu Jan 01 00:00:00 1970 +0000
536 536 summary: 2
537 537
538 538 ... grafts of grafts unfortunately can't
539 539 $ hg graft -q 13
540 540 $ hg log -r 'destination(13)'
541 541 All copies of a cset
542 542 $ hg log -r 'origin(13) or destination(origin(13))'
543 543 changeset: 2:5c095ad7e90f
544 544 user: test
545 545 date: Thu Jan 01 00:00:00 1970 +0000
546 546 summary: 2
547 547
548 548 changeset: 7:ef0ef43d49e7
549 549 parent: 0:68795b066622
550 550 user: foo
551 551 date: Thu Jan 01 00:00:00 1970 +0000
552 552 summary: 2
553 553
554 554 changeset: 13:9db0f28fd374
555 555 user: foo
556 556 date: Thu Jan 01 00:00:00 1970 +0000
557 557 summary: 2
558 558
559 559 changeset: 19:2e80e1351d6e
560 560 user: test
561 561 date: Thu Jan 01 00:00:00 1970 +0000
562 562 summary: 2
563 563
564 564 changeset: 21:7e61b508e709
565 565 branch: dev
566 566 user: foo
567 567 date: Thu Jan 01 00:00:00 1970 +0000
568 568 summary: 2
569 569
570 570 changeset: 22:1313d0a825e2
571 571 branch: dev
572 572 tag: tip
573 573 user: foo
574 574 date: Thu Jan 01 00:00:00 1970 +0000
575 575 summary: 2
576 576
577 577
578 578 graft works on complex revset
579 579
580 580 $ hg graft 'origin(13) or destination(origin(13))'
581 581 skipping ancestor revision 21
582 582 skipping ancestor revision 22
583 583 skipping revision 2 (already grafted to 22)
584 584 grafting revision 7
585 585 grafting revision 13
586 586 grafting revision 19
587 587 merging b
@@ -1,185 +1,185 b''
1 1 $ . "$TESTDIR/histedit-helpers.sh"
2 2
3 3 $ cat >> $HGRCPATH <<EOF
4 4 > [extensions]
5 5 > histedit=
6 6 > EOF
7 7
8 8 $ initrepo ()
9 9 > {
10 10 > hg init $1
11 11 > cd $1
12 12 > for x in a b c d e f ; do
13 13 > echo $x$x$x$x$x > $x
14 14 > hg add $x
15 15 > done
16 16 > hg ci -m 'Initial commit'
17 17 > for x in a b c d e f ; do
18 18 > echo $x > $x
19 19 > hg ci -m $x
20 20 > done
21 21 > echo 'I can haz no commute' > e
22 22 > hg ci -m 'does not commute with e'
23 23 > cd ..
24 24 > }
25 25
26 26 $ initrepo r
27 27 $ cd r
28 28 Initial generation of the command files
29 29
30 30 $ EDITED="$TESTTMP/editedhistory"
31 31 $ hg log --template 'pick {node|short} {rev} {desc}\n' -r 3 >> $EDITED
32 32 $ hg log --template 'pick {node|short} {rev} {desc}\n' -r 4 >> $EDITED
33 33 $ hg log --template 'fold {node|short} {rev} {desc}\n' -r 7 >> $EDITED
34 34 $ hg log --template 'pick {node|short} {rev} {desc}\n' -r 5 >> $EDITED
35 35 $ hg log --template 'pick {node|short} {rev} {desc}\n' -r 6 >> $EDITED
36 36 $ cat $EDITED
37 37 pick 65a9a84f33fd 3 c
38 38 pick 00f1c5383965 4 d
39 39 fold 39522b764e3d 7 does not commute with e
40 40 pick 7b4e2f4b7bcd 5 e
41 41 pick 500cac37a696 6 f
42 42
43 43 log before edit
44 44 $ hg log --graph
45 45 @ changeset: 7:39522b764e3d
46 46 | tag: tip
47 47 | user: test
48 48 | date: Thu Jan 01 00:00:00 1970 +0000
49 49 | summary: does not commute with e
50 50 |
51 51 o changeset: 6:500cac37a696
52 52 | user: test
53 53 | date: Thu Jan 01 00:00:00 1970 +0000
54 54 | summary: f
55 55 |
56 56 o changeset: 5:7b4e2f4b7bcd
57 57 | user: test
58 58 | date: Thu Jan 01 00:00:00 1970 +0000
59 59 | summary: e
60 60 |
61 61 o changeset: 4:00f1c5383965
62 62 | user: test
63 63 | date: Thu Jan 01 00:00:00 1970 +0000
64 64 | summary: d
65 65 |
66 66 o changeset: 3:65a9a84f33fd
67 67 | user: test
68 68 | date: Thu Jan 01 00:00:00 1970 +0000
69 69 | summary: c
70 70 |
71 71 o changeset: 2:da6535b52e45
72 72 | user: test
73 73 | date: Thu Jan 01 00:00:00 1970 +0000
74 74 | summary: b
75 75 |
76 76 o changeset: 1:c1f09da44841
77 77 | user: test
78 78 | date: Thu Jan 01 00:00:00 1970 +0000
79 79 | summary: a
80 80 |
81 81 o changeset: 0:1715188a53c7
82 82 user: test
83 83 date: Thu Jan 01 00:00:00 1970 +0000
84 84 summary: Initial commit
85 85
86 86
87 87 edit the history
88 88 $ hg histedit 3 --commands $EDITED 2>&1 | fixbundle
89 89 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
90 90 merging e
91 91 warning: conflicts during merge.
92 92 merging e incomplete! (edit conflicts, then use 'hg resolve --mark')
93 93 Fix up the change and run hg histedit --continue
94 94
95 95 fix up
96 96 $ echo 'I can haz no commute' > e
97 97 $ hg resolve --mark e
98 no unresolved files; you may continue your unfinished operation
98 no more unresolved files
99 99 $ cat > cat.py <<EOF
100 100 > import sys
101 101 > print open(sys.argv[1]).read()
102 102 > print
103 103 > print
104 104 > EOF
105 105 $ HGEDITOR="python cat.py" hg histedit --continue 2>&1 | fixbundle | grep -v '2 files removed'
106 106 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
107 107 d
108 108 ***
109 109 does not commute with e
110 110
111 111
112 112
113 113 HG: Enter commit message. Lines beginning with 'HG:' are removed.
114 114 HG: Leave message empty to abort commit.
115 115 HG: --
116 116 HG: user: test
117 117 HG: branch 'default'
118 118 HG: changed d
119 119 HG: changed e
120 120
121 121
122 122
123 123 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
124 124 0 files updated, 0 files merged, 0 files removed, 0 files unresolved
125 125 merging e
126 126 warning: conflicts during merge.
127 127 merging e incomplete! (edit conflicts, then use 'hg resolve --mark')
128 128 Fix up the change and run hg histedit --continue
129 129
130 130 just continue this time
131 131 $ hg revert -r 'p1()' e
132 132 $ hg resolve --mark e
133 no unresolved files; you may continue your unfinished operation
133 no more unresolved files
134 134 $ hg histedit --continue 2>&1 | fixbundle
135 135 0 files updated, 0 files merged, 0 files removed, 0 files unresolved
136 136 0 files updated, 0 files merged, 0 files removed, 0 files unresolved
137 137
138 138 log after edit
139 139 $ hg log --graph
140 140 @ changeset: 5:d9cf42e54966
141 141 | tag: tip
142 142 | user: test
143 143 | date: Thu Jan 01 00:00:00 1970 +0000
144 144 | summary: f
145 145 |
146 146 o changeset: 4:10486af2e984
147 147 | user: test
148 148 | date: Thu Jan 01 00:00:00 1970 +0000
149 149 | summary: d
150 150 |
151 151 o changeset: 3:65a9a84f33fd
152 152 | user: test
153 153 | date: Thu Jan 01 00:00:00 1970 +0000
154 154 | summary: c
155 155 |
156 156 o changeset: 2:da6535b52e45
157 157 | user: test
158 158 | date: Thu Jan 01 00:00:00 1970 +0000
159 159 | summary: b
160 160 |
161 161 o changeset: 1:c1f09da44841
162 162 | user: test
163 163 | date: Thu Jan 01 00:00:00 1970 +0000
164 164 | summary: a
165 165 |
166 166 o changeset: 0:1715188a53c7
167 167 user: test
168 168 date: Thu Jan 01 00:00:00 1970 +0000
169 169 summary: Initial commit
170 170
171 171
172 172 contents of e
173 173 $ hg cat e
174 174 I can haz no commute
175 175
176 176 manifest
177 177 $ hg manifest
178 178 a
179 179 b
180 180 c
181 181 d
182 182 e
183 183 f
184 184
185 185 $ cd ..
@@ -1,366 +1,366 b''
1 1 Test histedit extension: Fold commands
2 2 ======================================
3 3
4 4 This test file is dedicated to testing the fold command in non conflicting
5 5 case.
6 6
7 7 Initialization
8 8 ---------------
9 9
10 10
11 11 $ . "$TESTDIR/histedit-helpers.sh"
12 12
13 13 $ cat >> $HGRCPATH <<EOF
14 14 > [alias]
15 15 > logt = log --template '{rev}:{node|short} {desc|firstline}\n'
16 16 > [extensions]
17 17 > histedit=
18 18 > EOF
19 19
20 20
21 21 Simple folding
22 22 --------------------
23 23 $ initrepo ()
24 24 > {
25 25 > hg init r
26 26 > cd r
27 27 > for x in a b c d e f ; do
28 28 > echo $x > $x
29 29 > hg add $x
30 30 > hg ci -m $x
31 31 > done
32 32 > }
33 33
34 34 $ initrepo
35 35
36 36 log before edit
37 37 $ hg logt --graph
38 38 @ 5:652413bf663e f
39 39 |
40 40 o 4:e860deea161a e
41 41 |
42 42 o 3:055a42cdd887 d
43 43 |
44 44 o 2:177f92b77385 c
45 45 |
46 46 o 1:d2ae7f538514 b
47 47 |
48 48 o 0:cb9a9f314b8b a
49 49
50 50
51 51 $ hg histedit 177f92b77385 --commands - 2>&1 <<EOF | fixbundle
52 52 > pick e860deea161a e
53 53 > pick 652413bf663e f
54 54 > fold 177f92b77385 c
55 55 > pick 055a42cdd887 d
56 56 > EOF
57 57 0 files updated, 0 files merged, 4 files removed, 0 files unresolved
58 58 0 files updated, 0 files merged, 0 files removed, 0 files unresolved
59 59 0 files updated, 0 files merged, 0 files removed, 0 files unresolved
60 60 0 files updated, 0 files merged, 2 files removed, 0 files unresolved
61 61 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
62 62 0 files updated, 0 files merged, 0 files removed, 0 files unresolved
63 63 0 files updated, 0 files merged, 0 files removed, 0 files unresolved
64 64
65 65 log after edit
66 66 $ hg logt --graph
67 67 @ 4:9c277da72c9b d
68 68 |
69 69 o 3:6de59d13424a f
70 70 |
71 71 o 2:ee283cb5f2d5 e
72 72 |
73 73 o 1:d2ae7f538514 b
74 74 |
75 75 o 0:cb9a9f314b8b a
76 76
77 77
78 78 post-fold manifest
79 79 $ hg manifest
80 80 a
81 81 b
82 82 c
83 83 d
84 84 e
85 85 f
86 86
87 87
88 88 check histedit_source
89 89
90 90 $ hg log --debug --rev 3
91 91 changeset: 3:6de59d13424a8a13acd3e975514aed29dd0d9b2d
92 92 phase: draft
93 93 parent: 2:ee283cb5f2d5955443f23a27b697a04339e9a39a
94 94 parent: -1:0000000000000000000000000000000000000000
95 95 manifest: 3:81eede616954057198ead0b2c73b41d1f392829a
96 96 user: test
97 97 date: Thu Jan 01 00:00:00 1970 +0000
98 98 files+: c f
99 99 extra: branch=default
100 100 extra: histedit_source=a4f7421b80f79fcc59fff01bcbf4a53d127dd6d3,177f92b773850b59254aa5e923436f921b55483b
101 101 description:
102 102 f
103 103 ***
104 104 c
105 105
106 106
107 107
108 108 check saving last-message.txt
109 109
110 110 $ cat > $TESTTMP/abortfolding.py <<EOF
111 111 > from mercurial import util
112 112 > def abortfolding(ui, repo, hooktype, **kwargs):
113 113 > ctx = repo[kwargs.get('node')]
114 114 > if set(ctx.files()) == set(['c', 'd', 'f']):
115 115 > return True # abort folding commit only
116 116 > ui.warn('allow non-folding commit\\n')
117 117 > EOF
118 118 $ cat > .hg/hgrc <<EOF
119 119 > [hooks]
120 120 > pretxncommit.abortfolding = python:$TESTTMP/abortfolding.py:abortfolding
121 121 > EOF
122 122
123 123 $ cat > $TESTTMP/editor.sh << EOF
124 124 > echo "==== before editing"
125 125 > cat \$1
126 126 > echo "===="
127 127 > echo "check saving last-message.txt" >> \$1
128 128 > EOF
129 129
130 130 $ rm -f .hg/last-message.txt
131 131 $ HGEDITOR="sh $TESTTMP/editor.sh" hg histedit 6de59d13424a --commands - 2>&1 <<EOF | fixbundle
132 132 > pick 6de59d13424a f
133 133 > fold 9c277da72c9b d
134 134 > EOF
135 135 0 files updated, 0 files merged, 1 files removed, 0 files unresolved
136 136 allow non-folding commit
137 137 0 files updated, 0 files merged, 3 files removed, 0 files unresolved
138 138 ==== before editing
139 139 f
140 140 ***
141 141 c
142 142 ***
143 143 d
144 144
145 145
146 146
147 147 HG: Enter commit message. Lines beginning with 'HG:' are removed.
148 148 HG: Leave message empty to abort commit.
149 149 HG: --
150 150 HG: user: test
151 151 HG: branch 'default'
152 152 HG: changed c
153 153 HG: changed d
154 154 HG: changed f
155 155 ====
156 156 transaction abort!
157 157 rollback completed
158 158 abort: pretxncommit.abortfolding hook failed
159 159
160 160 $ cat .hg/last-message.txt
161 161 f
162 162 ***
163 163 c
164 164 ***
165 165 d
166 166
167 167
168 168
169 169 check saving last-message.txt
170 170
171 171 $ cd ..
172 172
173 173 folding and creating no new change doesn't break:
174 174 -------------------------------------------------
175 175
176 176 folded content is dropped during a merge. The folded commit should properly disappear.
177 177
178 178 $ mkdir fold-to-empty-test
179 179 $ cd fold-to-empty-test
180 180 $ hg init
181 181 $ printf "1\n2\n3\n" > file
182 182 $ hg add file
183 183 $ hg commit -m '1+2+3'
184 184 $ echo 4 >> file
185 185 $ hg commit -m '+4'
186 186 $ echo 5 >> file
187 187 $ hg commit -m '+5'
188 188 $ echo 6 >> file
189 189 $ hg commit -m '+6'
190 190 $ hg logt --graph
191 191 @ 3:251d831eeec5 +6
192 192 |
193 193 o 2:888f9082bf99 +5
194 194 |
195 195 o 1:617f94f13c0f +4
196 196 |
197 197 o 0:0189ba417d34 1+2+3
198 198
199 199
200 200 $ hg histedit 1 --commands - << EOF
201 201 > pick 617f94f13c0f 1 +4
202 202 > drop 888f9082bf99 2 +5
203 203 > fold 251d831eeec5 3 +6
204 204 > EOF
205 205 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
206 206 merging file
207 207 warning: conflicts during merge.
208 208 merging file incomplete! (edit conflicts, then use 'hg resolve --mark')
209 209 Fix up the change and run hg histedit --continue
210 210 [1]
211 211 There were conflicts, we keep P1 content. This
212 212 should effectively drop the changes from +6.
213 213 $ hg status
214 214 M file
215 215 ? file.orig
216 216 $ hg resolve -l
217 217 U file
218 218 $ hg revert -r 'p1()' file
219 219 $ hg resolve --mark file
220 no unresolved files; you may continue your unfinished operation
220 no more unresolved files
221 221 $ hg histedit --continue
222 222 0 files updated, 0 files merged, 0 files removed, 0 files unresolved
223 223 saved backup bundle to $TESTTMP/*-backup.hg (glob)
224 224 $ hg logt --graph
225 225 @ 1:617f94f13c0f +4
226 226 |
227 227 o 0:0189ba417d34 1+2+3
228 228
229 229
230 230 $ cd ..
231 231
232 232
233 233 Test fold through dropped
234 234 -------------------------
235 235
236 236
237 237 Test corner case where folded revision is separated from its parent by a
238 238 dropped revision.
239 239
240 240
241 241 $ hg init fold-with-dropped
242 242 $ cd fold-with-dropped
243 243 $ printf "1\n2\n3\n" > file
244 244 $ hg commit -Am '1+2+3'
245 245 adding file
246 246 $ echo 4 >> file
247 247 $ hg commit -m '+4'
248 248 $ echo 5 >> file
249 249 $ hg commit -m '+5'
250 250 $ echo 6 >> file
251 251 $ hg commit -m '+6'
252 252 $ hg logt -G
253 253 @ 3:251d831eeec5 +6
254 254 |
255 255 o 2:888f9082bf99 +5
256 256 |
257 257 o 1:617f94f13c0f +4
258 258 |
259 259 o 0:0189ba417d34 1+2+3
260 260
261 261 $ hg histedit 1 --commands - << EOF
262 262 > pick 617f94f13c0f 1 +4
263 263 > drop 888f9082bf99 2 +5
264 264 > fold 251d831eeec5 3 +6
265 265 > EOF
266 266 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
267 267 merging file
268 268 warning: conflicts during merge.
269 269 merging file incomplete! (edit conflicts, then use 'hg resolve --mark')
270 270 Fix up the change and run hg histedit --continue
271 271 [1]
272 272 $ cat > file << EOF
273 273 > 1
274 274 > 2
275 275 > 3
276 276 > 4
277 277 > 5
278 278 > EOF
279 279 $ hg resolve --mark file
280 no unresolved files; you may continue your unfinished operation
280 no more unresolved files
281 281 $ hg commit -m '+5.2'
282 282 created new head
283 283 $ echo 6 >> file
284 284 $ HGEDITOR=cat hg histedit --continue
285 285 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
286 286 +4
287 287 ***
288 288 +5.2
289 289 ***
290 290 +6
291 291
292 292
293 293
294 294 HG: Enter commit message. Lines beginning with 'HG:' are removed.
295 295 HG: Leave message empty to abort commit.
296 296 HG: --
297 297 HG: user: test
298 298 HG: branch 'default'
299 299 HG: changed file
300 300 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
301 301 0 files updated, 0 files merged, 0 files removed, 0 files unresolved
302 302 saved backup bundle to $TESTTMP/fold-with-dropped/.hg/strip-backup/617f94f13c0f-backup.hg (glob)
303 303 $ hg logt -G
304 304 @ 1:10c647b2cdd5 +4
305 305 |
306 306 o 0:0189ba417d34 1+2+3
307 307
308 308 $ hg export tip
309 309 # HG changeset patch
310 310 # User test
311 311 # Date 0 0
312 312 # Thu Jan 01 00:00:00 1970 +0000
313 313 # Node ID 10c647b2cdd54db0603ecb99b2ff5ce66d5a5323
314 314 # Parent 0189ba417d34df9dda55f88b637dcae9917b5964
315 315 +4
316 316 ***
317 317 +5.2
318 318 ***
319 319 +6
320 320
321 321 diff -r 0189ba417d34 -r 10c647b2cdd5 file
322 322 --- a/file Thu Jan 01 00:00:00 1970 +0000
323 323 +++ b/file Thu Jan 01 00:00:00 1970 +0000
324 324 @@ -1,3 +1,6 @@
325 325 1
326 326 2
327 327 3
328 328 +4
329 329 +5
330 330 +6
331 331 $ cd ..
332 332
333 333
334 334 Folding with initial rename (issue3729)
335 335 ---------------------------------------
336 336
337 337 $ hg init fold-rename
338 338 $ cd fold-rename
339 339 $ echo a > a.txt
340 340 $ hg add a.txt
341 341 $ hg commit -m a
342 342 $ hg rename a.txt b.txt
343 343 $ hg commit -m rename
344 344 $ echo b >> b.txt
345 345 $ hg commit -m b
346 346
347 347 $ hg logt --follow b.txt
348 348 2:e0371e0426bc b
349 349 1:1c4f440a8085 rename
350 350 0:6c795aa153cb a
351 351
352 352 $ hg histedit 1c4f440a8085 --commands - 2>&1 << EOF | fixbundle
353 353 > pick 1c4f440a8085 rename
354 354 > fold e0371e0426bc b
355 355 > EOF
356 356 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
357 357 reverting b.txt
358 358 1 files updated, 0 files merged, 1 files removed, 0 files unresolved
359 359 1 files updated, 0 files merged, 1 files removed, 0 files unresolved
360 360 0 files updated, 0 files merged, 0 files removed, 0 files unresolved
361 361
362 362 $ hg logt --follow b.txt
363 363 1:cf858d235c76 rename
364 364 0:6c795aa153cb a
365 365
366 366 $ cd ..
@@ -1,298 +1,298 b''
1 1 $ . "$TESTDIR/histedit-helpers.sh"
2 2
3 3 $ cat >> $HGRCPATH <<EOF
4 4 > [extensions]
5 5 > histedit=
6 6 > EOF
7 7
8 8 $ initrepo ()
9 9 > {
10 10 > hg init $1
11 11 > cd $1
12 12 > for x in a b c d e f ; do
13 13 > echo $x$x$x$x$x > $x
14 14 > hg add $x
15 15 > done
16 16 > hg ci -m 'Initial commit'
17 17 > for x in a b c d e f ; do
18 18 > echo $x > $x
19 19 > hg ci -m $x
20 20 > done
21 21 > echo 'I can haz no commute' > e
22 22 > hg ci -m 'does not commute with e'
23 23 > cd ..
24 24 > }
25 25
26 26 $ initrepo r1
27 27 $ cd r1
28 28
29 29 Initial generation of the command files
30 30
31 31 $ EDITED="$TESTTMP/editedhistory"
32 32 $ hg log --template 'pick {node|short} {rev} {desc}\n' -r 3 >> $EDITED
33 33 $ hg log --template 'pick {node|short} {rev} {desc}\n' -r 4 >> $EDITED
34 34 $ hg log --template 'pick {node|short} {rev} {desc}\n' -r 7 >> $EDITED
35 35 $ hg log --template 'pick {node|short} {rev} {desc}\n' -r 5 >> $EDITED
36 36 $ hg log --template 'pick {node|short} {rev} {desc}\n' -r 6 >> $EDITED
37 37 $ cat $EDITED
38 38 pick 65a9a84f33fd 3 c
39 39 pick 00f1c5383965 4 d
40 40 pick 39522b764e3d 7 does not commute with e
41 41 pick 7b4e2f4b7bcd 5 e
42 42 pick 500cac37a696 6 f
43 43
44 44 log before edit
45 45 $ hg log --graph
46 46 @ changeset: 7:39522b764e3d
47 47 | tag: tip
48 48 | user: test
49 49 | date: Thu Jan 01 00:00:00 1970 +0000
50 50 | summary: does not commute with e
51 51 |
52 52 o changeset: 6:500cac37a696
53 53 | user: test
54 54 | date: Thu Jan 01 00:00:00 1970 +0000
55 55 | summary: f
56 56 |
57 57 o changeset: 5:7b4e2f4b7bcd
58 58 | user: test
59 59 | date: Thu Jan 01 00:00:00 1970 +0000
60 60 | summary: e
61 61 |
62 62 o changeset: 4:00f1c5383965
63 63 | user: test
64 64 | date: Thu Jan 01 00:00:00 1970 +0000
65 65 | summary: d
66 66 |
67 67 o changeset: 3:65a9a84f33fd
68 68 | user: test
69 69 | date: Thu Jan 01 00:00:00 1970 +0000
70 70 | summary: c
71 71 |
72 72 o changeset: 2:da6535b52e45
73 73 | user: test
74 74 | date: Thu Jan 01 00:00:00 1970 +0000
75 75 | summary: b
76 76 |
77 77 o changeset: 1:c1f09da44841
78 78 | user: test
79 79 | date: Thu Jan 01 00:00:00 1970 +0000
80 80 | summary: a
81 81 |
82 82 o changeset: 0:1715188a53c7
83 83 user: test
84 84 date: Thu Jan 01 00:00:00 1970 +0000
85 85 summary: Initial commit
86 86
87 87
88 88 edit the history
89 89 $ hg histedit 3 --commands $EDITED 2>&1 | fixbundle
90 90 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
91 91 merging e
92 92 warning: conflicts during merge.
93 93 merging e incomplete! (edit conflicts, then use 'hg resolve --mark')
94 94 Fix up the change and run hg histedit --continue
95 95
96 96 abort the edit
97 97 $ hg histedit --abort 2>&1 | fixbundle
98 98 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
99 99
100 100
101 101 second edit set
102 102
103 103 $ hg log --graph
104 104 @ changeset: 7:39522b764e3d
105 105 | tag: tip
106 106 | user: test
107 107 | date: Thu Jan 01 00:00:00 1970 +0000
108 108 | summary: does not commute with e
109 109 |
110 110 o changeset: 6:500cac37a696
111 111 | user: test
112 112 | date: Thu Jan 01 00:00:00 1970 +0000
113 113 | summary: f
114 114 |
115 115 o changeset: 5:7b4e2f4b7bcd
116 116 | user: test
117 117 | date: Thu Jan 01 00:00:00 1970 +0000
118 118 | summary: e
119 119 |
120 120 o changeset: 4:00f1c5383965
121 121 | user: test
122 122 | date: Thu Jan 01 00:00:00 1970 +0000
123 123 | summary: d
124 124 |
125 125 o changeset: 3:65a9a84f33fd
126 126 | user: test
127 127 | date: Thu Jan 01 00:00:00 1970 +0000
128 128 | summary: c
129 129 |
130 130 o changeset: 2:da6535b52e45
131 131 | user: test
132 132 | date: Thu Jan 01 00:00:00 1970 +0000
133 133 | summary: b
134 134 |
135 135 o changeset: 1:c1f09da44841
136 136 | user: test
137 137 | date: Thu Jan 01 00:00:00 1970 +0000
138 138 | summary: a
139 139 |
140 140 o changeset: 0:1715188a53c7
141 141 user: test
142 142 date: Thu Jan 01 00:00:00 1970 +0000
143 143 summary: Initial commit
144 144
145 145
146 146 edit the history
147 147 $ hg histedit 3 --commands $EDITED 2>&1 | fixbundle
148 148 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
149 149 merging e
150 150 warning: conflicts during merge.
151 151 merging e incomplete! (edit conflicts, then use 'hg resolve --mark')
152 152 Fix up the change and run hg histedit --continue
153 153
154 154 fix up
155 155 $ echo 'I can haz no commute' > e
156 156 $ hg resolve --mark e
157 no unresolved files; you may continue your unfinished operation
157 no more unresolved files
158 158 $ hg histedit --continue 2>&1 | fixbundle
159 159 0 files updated, 0 files merged, 0 files removed, 0 files unresolved
160 160 merging e
161 161 warning: conflicts during merge.
162 162 merging e incomplete! (edit conflicts, then use 'hg resolve --mark')
163 163 Fix up the change and run hg histedit --continue
164 164
165 165 This failure is caused by 7b4e2f4b7bcd "e" not rebasing the non commutative
166 166 former children.
167 167
168 168 just continue this time
169 169 $ hg revert -r 'p1()' e
170 170 $ hg resolve --mark e
171 no unresolved files; you may continue your unfinished operation
171 no more unresolved files
172 172 $ hg histedit --continue 2>&1 | fixbundle
173 173 0 files updated, 0 files merged, 0 files removed, 0 files unresolved
174 174 0 files updated, 0 files merged, 0 files removed, 0 files unresolved
175 175
176 176 log after edit
177 177 $ hg log --graph
178 178 @ changeset: 6:7efe1373e4bc
179 179 | tag: tip
180 180 | user: test
181 181 | date: Thu Jan 01 00:00:00 1970 +0000
182 182 | summary: f
183 183 |
184 184 o changeset: 5:e334d87a1e55
185 185 | user: test
186 186 | date: Thu Jan 01 00:00:00 1970 +0000
187 187 | summary: does not commute with e
188 188 |
189 189 o changeset: 4:00f1c5383965
190 190 | user: test
191 191 | date: Thu Jan 01 00:00:00 1970 +0000
192 192 | summary: d
193 193 |
194 194 o changeset: 3:65a9a84f33fd
195 195 | user: test
196 196 | date: Thu Jan 01 00:00:00 1970 +0000
197 197 | summary: c
198 198 |
199 199 o changeset: 2:da6535b52e45
200 200 | user: test
201 201 | date: Thu Jan 01 00:00:00 1970 +0000
202 202 | summary: b
203 203 |
204 204 o changeset: 1:c1f09da44841
205 205 | user: test
206 206 | date: Thu Jan 01 00:00:00 1970 +0000
207 207 | summary: a
208 208 |
209 209 o changeset: 0:1715188a53c7
210 210 user: test
211 211 date: Thu Jan 01 00:00:00 1970 +0000
212 212 summary: Initial commit
213 213
214 214
215 215 start over
216 216
217 217 $ cd ..
218 218
219 219 $ initrepo r2
220 220 $ cd r2
221 221 $ rm $EDITED
222 222 $ hg log --template 'pick {node|short} {rev} {desc}\n' -r 3 >> $EDITED
223 223 $ hg log --template 'pick {node|short} {rev} {desc}\n' -r 4 >> $EDITED
224 224 $ hg log --template 'mess {node|short} {rev} {desc}\n' -r 7 >> $EDITED
225 225 $ hg log --template 'pick {node|short} {rev} {desc}\n' -r 5 >> $EDITED
226 226 $ hg log --template 'pick {node|short} {rev} {desc}\n' -r 6 >> $EDITED
227 227 $ cat $EDITED
228 228 pick 65a9a84f33fd 3 c
229 229 pick 00f1c5383965 4 d
230 230 mess 39522b764e3d 7 does not commute with e
231 231 pick 7b4e2f4b7bcd 5 e
232 232 pick 500cac37a696 6 f
233 233
234 234 edit the history, this time with a fold action
235 235 $ hg histedit 3 --commands $EDITED 2>&1 | fixbundle
236 236 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
237 237 merging e
238 238 warning: conflicts during merge.
239 239 merging e incomplete! (edit conflicts, then use 'hg resolve --mark')
240 240 Fix up the change and run hg histedit --continue
241 241
242 242 $ echo 'I can haz no commute' > e
243 243 $ hg resolve --mark e
244 no unresolved files; you may continue your unfinished operation
244 no more unresolved files
245 245 $ hg histedit --continue 2>&1 | fixbundle
246 246 0 files updated, 0 files merged, 0 files removed, 0 files unresolved
247 247 merging e
248 248 warning: conflicts during merge.
249 249 merging e incomplete! (edit conflicts, then use 'hg resolve --mark')
250 250 Fix up the change and run hg histedit --continue
251 251 second edit also fails, but just continue
252 252 $ hg revert -r 'p1()' e
253 253 $ hg resolve --mark e
254 no unresolved files; you may continue your unfinished operation
254 no more unresolved files
255 255 $ hg histedit --continue 2>&1 | fixbundle
256 256 0 files updated, 0 files merged, 0 files removed, 0 files unresolved
257 257 0 files updated, 0 files merged, 0 files removed, 0 files unresolved
258 258
259 259 post message fix
260 260 $ hg log --graph
261 261 @ changeset: 6:7efe1373e4bc
262 262 | tag: tip
263 263 | user: test
264 264 | date: Thu Jan 01 00:00:00 1970 +0000
265 265 | summary: f
266 266 |
267 267 o changeset: 5:e334d87a1e55
268 268 | user: test
269 269 | date: Thu Jan 01 00:00:00 1970 +0000
270 270 | summary: does not commute with e
271 271 |
272 272 o changeset: 4:00f1c5383965
273 273 | user: test
274 274 | date: Thu Jan 01 00:00:00 1970 +0000
275 275 | summary: d
276 276 |
277 277 o changeset: 3:65a9a84f33fd
278 278 | user: test
279 279 | date: Thu Jan 01 00:00:00 1970 +0000
280 280 | summary: c
281 281 |
282 282 o changeset: 2:da6535b52e45
283 283 | user: test
284 284 | date: Thu Jan 01 00:00:00 1970 +0000
285 285 | summary: b
286 286 |
287 287 o changeset: 1:c1f09da44841
288 288 | user: test
289 289 | date: Thu Jan 01 00:00:00 1970 +0000
290 290 | summary: a
291 291 |
292 292 o changeset: 0:1715188a53c7
293 293 user: test
294 294 date: Thu Jan 01 00:00:00 1970 +0000
295 295 summary: Initial commit
296 296
297 297
298 298 $ cd ..
@@ -1,1156 +1,1156 b''
1 1 $ cat <<EOF >> $HGRCPATH
2 2 > [extensions]
3 3 > keyword =
4 4 > mq =
5 5 > notify =
6 6 > record =
7 7 > transplant =
8 8 > [ui]
9 9 > interactive = true
10 10 > EOF
11 11
12 12 hide outer repo
13 13 $ hg init
14 14
15 15 Run kwdemo before [keyword] files are set up
16 16 as it would succeed without uisetup otherwise
17 17
18 18 $ hg --quiet kwdemo
19 19 [extensions]
20 20 keyword =
21 21 [keyword]
22 22 demo.txt =
23 23 [keywordset]
24 24 svn = False
25 25 [keywordmaps]
26 26 Author = {author|user}
27 27 Date = {date|utcdate}
28 28 Header = {root}/{file},v {node|short} {date|utcdate} {author|user}
29 29 Id = {file|basename},v {node|short} {date|utcdate} {author|user}
30 30 RCSFile = {file|basename},v
31 31 RCSfile = {file|basename},v
32 32 Revision = {node|short}
33 33 Source = {root}/{file},v
34 34 $Author: test $
35 35 $Date: ????/??/?? ??:??:?? $ (glob)
36 36 $Header: */demo.txt,v ???????????? ????/??/?? ??:??:?? test $ (glob)
37 37 $Id: demo.txt,v ???????????? ????/??/?? ??:??:?? test $ (glob)
38 38 $RCSFile: demo.txt,v $
39 39 $RCSfile: demo.txt,v $
40 40 $Revision: ???????????? $ (glob)
41 41 $Source: */demo.txt,v $ (glob)
42 42
43 43 $ hg --quiet kwdemo "Branch = {branches}"
44 44 [extensions]
45 45 keyword =
46 46 [keyword]
47 47 demo.txt =
48 48 [keywordset]
49 49 svn = False
50 50 [keywordmaps]
51 51 Branch = {branches}
52 52 $Branch: demobranch $
53 53
54 54 $ cat <<EOF >> $HGRCPATH
55 55 > [keyword]
56 56 > ** =
57 57 > b = ignore
58 58 > i = ignore
59 59 > [hooks]
60 60 > EOF
61 61 $ cp $HGRCPATH $HGRCPATH.nohooks
62 62 > cat <<EOF >> $HGRCPATH
63 63 > commit=
64 64 > commit.test=cp a hooktest
65 65 > EOF
66 66
67 67 $ hg init Test-bndl
68 68 $ cd Test-bndl
69 69
70 70 kwshrink should exit silently in empty/invalid repo
71 71
72 72 $ hg kwshrink
73 73
74 74 Symlinks cannot be created on Windows.
75 75 A bundle to test this was made with:
76 76 hg init t
77 77 cd t
78 78 echo a > a
79 79 ln -s a sym
80 80 hg add sym
81 81 hg ci -m addsym -u mercurial
82 82 hg bundle --base null ../test-keyword.hg
83 83
84 84 $ hg pull -u "$TESTDIR"/bundles/test-keyword.hg
85 85 pulling from *test-keyword.hg (glob)
86 86 requesting all changes
87 87 adding changesets
88 88 adding manifests
89 89 adding file changes
90 90 added 1 changesets with 1 changes to 1 files
91 91 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
92 92
93 93 $ echo 'expand $Id$' > a
94 94 $ echo 'do not process $Id:' >> a
95 95 $ echo 'xxx $' >> a
96 96 $ echo 'ignore $Id$' > b
97 97
98 98 Output files as they were created
99 99
100 100 $ cat a b
101 101 expand $Id$
102 102 do not process $Id:
103 103 xxx $
104 104 ignore $Id$
105 105
106 106 no kwfiles
107 107
108 108 $ hg kwfiles
109 109
110 110 untracked candidates
111 111
112 112 $ hg -v kwfiles --unknown
113 113 k a
114 114
115 115 Add files and check status
116 116
117 117 $ hg addremove
118 118 adding a
119 119 adding b
120 120 $ hg status
121 121 A a
122 122 A b
123 123
124 124
125 125 Default keyword expansion including commit hook
126 126 Interrupted commit should not change state or run commit hook
127 127
128 128 $ hg --debug commit
129 129 abort: empty commit message
130 130 [255]
131 131 $ hg status
132 132 A a
133 133 A b
134 134
135 135 Commit with several checks
136 136
137 137 $ hg --debug commit -mabsym -u 'User Name <user@example.com>'
138 138 a
139 139 b
140 140 overwriting a expanding keywords
141 141 running hook commit.test: cp a hooktest
142 142 committed changeset 1:ef63ca68695bc9495032c6fda1350c71e6d256e9
143 143 $ hg status
144 144 ? hooktest
145 145 $ hg debugrebuildstate
146 146 $ hg --quiet identify
147 147 ef63ca68695b
148 148
149 149 cat files in working directory with keywords expanded
150 150
151 151 $ cat a b
152 152 expand $Id: a,v ef63ca68695b 1970/01/01 00:00:00 user $
153 153 do not process $Id:
154 154 xxx $
155 155 ignore $Id$
156 156
157 157 hg cat files and symlink, no expansion
158 158
159 159 $ hg cat sym a b && echo
160 160 expand $Id: a,v ef63ca68695b 1970/01/01 00:00:00 user $
161 161 do not process $Id:
162 162 xxx $
163 163 ignore $Id$
164 164 a
165 165
166 166 $ diff a hooktest
167 167
168 168 $ cp $HGRCPATH.nohooks $HGRCPATH
169 169 $ rm hooktest
170 170
171 171 hg status of kw-ignored binary file starting with '\1\n'
172 172
173 173 >>> open("i", "wb").write("\1\nfoo")
174 174 $ hg -q commit -Am metasep i
175 175 $ hg status
176 176 >>> open("i", "wb").write("\1\nbar")
177 177 $ hg status
178 178 M i
179 179 $ hg -q commit -m "modify metasep" i
180 180 $ hg status --rev 2:3
181 181 M i
182 182 $ touch empty
183 183 $ hg -q commit -A -m "another file"
184 184 $ hg status -A --rev 3:4 i
185 185 C i
186 186
187 187 $ hg -q strip -n 2
188 188
189 189 Test hook execution
190 190
191 191 bundle
192 192
193 193 $ hg bundle --base null ../kw.hg
194 194 2 changesets found
195 195 $ cd ..
196 196 $ hg init Test
197 197 $ cd Test
198 198
199 199 Notify on pull to check whether keywords stay as is in email
200 200 ie. if patch.diff wrapper acts as it should
201 201
202 202 $ cat <<EOF >> $HGRCPATH
203 203 > [hooks]
204 204 > incoming.notify = python:hgext.notify.hook
205 205 > [notify]
206 206 > sources = pull
207 207 > diffstat = False
208 208 > maxsubject = 15
209 209 > [reposubs]
210 210 > * = Test
211 211 > EOF
212 212
213 213 Pull from bundle and trigger notify
214 214
215 215 $ hg pull -u ../kw.hg
216 216 pulling from ../kw.hg
217 217 requesting all changes
218 218 adding changesets
219 219 adding manifests
220 220 adding file changes
221 221 added 2 changesets with 3 changes to 3 files
222 222 Content-Type: text/plain; charset="us-ascii"
223 223 MIME-Version: 1.0
224 224 Content-Transfer-Encoding: 7bit
225 225 Date: * (glob)
226 226 Subject: changeset in...
227 227 From: mercurial
228 228 X-Hg-Notification: changeset a2392c293916
229 229 Message-Id: <hg.a2392c293916*> (glob)
230 230 To: Test
231 231
232 232 changeset a2392c293916 in $TESTTMP/Test (glob)
233 233 details: $TESTTMP/Test?cmd=changeset;node=a2392c293916
234 234 description:
235 235 addsym
236 236
237 237 diffs (6 lines):
238 238
239 239 diff -r 000000000000 -r a2392c293916 sym
240 240 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
241 241 +++ b/sym Sat Feb 09 20:25:47 2008 +0100
242 242 @@ -0,0 +1,1 @@
243 243 +a
244 244 \ No newline at end of file
245 245 Content-Type: text/plain; charset="us-ascii"
246 246 MIME-Version: 1.0
247 247 Content-Transfer-Encoding: 7bit
248 248 Date:* (glob)
249 249 Subject: changeset in...
250 250 From: User Name <user@example.com>
251 251 X-Hg-Notification: changeset ef63ca68695b
252 252 Message-Id: <hg.ef63ca68695b*> (glob)
253 253 To: Test
254 254
255 255 changeset ef63ca68695b in $TESTTMP/Test (glob)
256 256 details: $TESTTMP/Test?cmd=changeset;node=ef63ca68695b
257 257 description:
258 258 absym
259 259
260 260 diffs (12 lines):
261 261
262 262 diff -r a2392c293916 -r ef63ca68695b a
263 263 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
264 264 +++ b/a Thu Jan 01 00:00:00 1970 +0000
265 265 @@ -0,0 +1,3 @@
266 266 +expand $Id$
267 267 +do not process $Id:
268 268 +xxx $
269 269 diff -r a2392c293916 -r ef63ca68695b b
270 270 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
271 271 +++ b/b Thu Jan 01 00:00:00 1970 +0000
272 272 @@ -0,0 +1,1 @@
273 273 +ignore $Id$
274 274 3 files updated, 0 files merged, 0 files removed, 0 files unresolved
275 275
276 276 $ cp $HGRCPATH.nohooks $HGRCPATH
277 277
278 278 Touch files and check with status
279 279
280 280 $ touch a b
281 281 $ hg status
282 282
283 283 Update and expand
284 284
285 285 $ rm sym a b
286 286 $ hg update -C
287 287 3 files updated, 0 files merged, 0 files removed, 0 files unresolved
288 288 $ cat a b
289 289 expand $Id: a,v ef63ca68695b 1970/01/01 00:00:00 user $
290 290 do not process $Id:
291 291 xxx $
292 292 ignore $Id$
293 293
294 294 Check whether expansion is filewise and file mode is preserved
295 295
296 296 $ echo '$Id$' > c
297 297 $ echo 'tests for different changenodes' >> c
298 298 #if unix-permissions
299 299 $ chmod 600 c
300 300 $ ls -l c | cut -b 1-10
301 301 -rw-------
302 302 #endif
303 303
304 304 commit file c
305 305
306 306 $ hg commit -A -mcndiff -d '1 0' -u 'User Name <user@example.com>'
307 307 adding c
308 308 #if unix-permissions
309 309 $ ls -l c | cut -b 1-10
310 310 -rw-------
311 311 #endif
312 312
313 313 force expansion
314 314
315 315 $ hg -v kwexpand
316 316 overwriting a expanding keywords
317 317 overwriting c expanding keywords
318 318
319 319 compare changenodes in a and c
320 320
321 321 $ cat a c
322 322 expand $Id: a,v ef63ca68695b 1970/01/01 00:00:00 user $
323 323 do not process $Id:
324 324 xxx $
325 325 $Id: c,v 40a904bbbe4c 1970/01/01 00:00:01 user $
326 326 tests for different changenodes
327 327
328 328 record
329 329
330 330 $ echo '$Id$' > r
331 331 $ hg add r
332 332
333 333 record chunk
334 334
335 335 >>> lines = open('a', 'rb').readlines()
336 336 >>> lines.insert(1, 'foo\n')
337 337 >>> lines.append('bar\n')
338 338 >>> open('a', 'wb').writelines(lines)
339 339 $ hg record -d '10 1' -m rectest a<<EOF
340 340 > y
341 341 > y
342 342 > n
343 343 > EOF
344 344 diff --git a/a b/a
345 345 2 hunks, 2 lines changed
346 346 examine changes to 'a'? [Ynesfdaq?]
347 347 @@ -1,3 +1,4 @@
348 348 expand $Id$
349 349 +foo
350 350 do not process $Id:
351 351 xxx $
352 352 record change 1/2 to 'a'? [Ynesfdaq?]
353 353 @@ -2,2 +3,3 @@
354 354 do not process $Id:
355 355 xxx $
356 356 +bar
357 357 record change 2/2 to 'a'? [Ynesfdaq?]
358 358
359 359 $ hg identify
360 360 5f5eb23505c3+ tip
361 361 $ hg status
362 362 M a
363 363 A r
364 364
365 365 Cat modified file a
366 366
367 367 $ cat a
368 368 expand $Id: a,v 5f5eb23505c3 1970/01/01 00:00:10 test $
369 369 foo
370 370 do not process $Id:
371 371 xxx $
372 372 bar
373 373
374 374 Diff remaining chunk
375 375
376 376 $ hg diff a
377 377 diff -r 5f5eb23505c3 a
378 378 --- a/a Thu Jan 01 00:00:09 1970 -0000
379 379 +++ b/a * (glob)
380 380 @@ -2,3 +2,4 @@
381 381 foo
382 382 do not process $Id:
383 383 xxx $
384 384 +bar
385 385
386 386 $ hg rollback
387 387 repository tip rolled back to revision 2 (undo commit)
388 388 working directory now based on revision 2
389 389
390 390 Record all chunks in file a
391 391
392 392 $ echo foo > msg
393 393
394 394 - do not use "hg record -m" here!
395 395
396 396 $ hg record -l msg -d '11 1' a<<EOF
397 397 > y
398 398 > y
399 399 > y
400 400 > EOF
401 401 diff --git a/a b/a
402 402 2 hunks, 2 lines changed
403 403 examine changes to 'a'? [Ynesfdaq?]
404 404 @@ -1,3 +1,4 @@
405 405 expand $Id$
406 406 +foo
407 407 do not process $Id:
408 408 xxx $
409 409 record change 1/2 to 'a'? [Ynesfdaq?]
410 410 @@ -2,2 +3,3 @@
411 411 do not process $Id:
412 412 xxx $
413 413 +bar
414 414 record change 2/2 to 'a'? [Ynesfdaq?]
415 415
416 416 File a should be clean
417 417
418 418 $ hg status -A a
419 419 C a
420 420
421 421 rollback and revert expansion
422 422
423 423 $ cat a
424 424 expand $Id: a,v 78e0a02d76aa 1970/01/01 00:00:11 test $
425 425 foo
426 426 do not process $Id:
427 427 xxx $
428 428 bar
429 429 $ hg --verbose rollback
430 430 repository tip rolled back to revision 2 (undo commit)
431 431 working directory now based on revision 2
432 432 overwriting a expanding keywords
433 433 $ hg status a
434 434 M a
435 435 $ cat a
436 436 expand $Id: a,v ef63ca68695b 1970/01/01 00:00:00 user $
437 437 foo
438 438 do not process $Id:
439 439 xxx $
440 440 bar
441 441 $ echo '$Id$' > y
442 442 $ echo '$Id$' > z
443 443 $ hg add y
444 444 $ hg commit -Am "rollback only" z
445 445 $ cat z
446 446 $Id: z,v 45a5d3adce53 1970/01/01 00:00:00 test $
447 447 $ hg --verbose rollback
448 448 repository tip rolled back to revision 2 (undo commit)
449 449 working directory now based on revision 2
450 450 overwriting z shrinking keywords
451 451
452 452 Only z should be overwritten
453 453
454 454 $ hg status a y z
455 455 M a
456 456 A y
457 457 A z
458 458 $ cat z
459 459 $Id$
460 460 $ hg forget y z
461 461 $ rm y z
462 462
463 463 record added file alone
464 464
465 465 $ hg -v record -l msg -d '12 2' r<<EOF
466 466 > y
467 467 > EOF
468 468 diff --git a/r b/r
469 469 new file mode 100644
470 470 examine changes to 'r'? [Ynesfdaq?]
471 471 r
472 472 committed changeset 3:82a2f715724d
473 473 overwriting r expanding keywords
474 474 - status call required for dirstate.normallookup() check
475 475 $ hg status r
476 476 $ hg --verbose rollback
477 477 repository tip rolled back to revision 2 (undo commit)
478 478 working directory now based on revision 2
479 479 overwriting r shrinking keywords
480 480 $ hg forget r
481 481 $ rm msg r
482 482 $ hg update -C
483 483 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
484 484
485 485 record added keyword ignored file
486 486
487 487 $ echo '$Id$' > i
488 488 $ hg add i
489 489 $ hg --verbose record -d '13 1' -m recignored<<EOF
490 490 > y
491 491 > EOF
492 492 diff --git a/i b/i
493 493 new file mode 100644
494 494 examine changes to 'i'? [Ynesfdaq?]
495 495 i
496 496 committed changeset 3:9f40ceb5a072
497 497 $ cat i
498 498 $Id$
499 499 $ hg -q rollback
500 500 $ hg forget i
501 501 $ rm i
502 502
503 503 amend
504 504
505 505 $ echo amend >> a
506 506 $ echo amend >> b
507 507 $ hg -q commit -d '14 1' -m 'prepare amend'
508 508
509 509 $ hg --debug commit --amend -d '15 1' -m 'amend without changes' | grep keywords
510 510 invalid branchheads cache (served): tip differs
511 511 overwriting a expanding keywords
512 512 $ hg -q id
513 513 67d8c481a6be
514 514 $ head -1 a
515 515 expand $Id: a,v 67d8c481a6be 1970/01/01 00:00:15 test $
516 516
517 517 $ hg -q strip -n tip
518 518
519 519 Test patch queue repo
520 520
521 521 $ hg init --mq
522 522 $ hg qimport -r tip -n mqtest.diff
523 523 $ hg commit --mq -m mqtest
524 524
525 525 Keywords should not be expanded in patch
526 526
527 527 $ cat .hg/patches/mqtest.diff
528 528 # HG changeset patch
529 529 # User User Name <user@example.com>
530 530 # Date 1 0
531 531 # Thu Jan 01 00:00:01 1970 +0000
532 532 # Node ID 40a904bbbe4cd4ab0a1f28411e35db26341a40ad
533 533 # Parent ef63ca68695bc9495032c6fda1350c71e6d256e9
534 534 cndiff
535 535
536 536 diff -r ef63ca68695b -r 40a904bbbe4c c
537 537 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
538 538 +++ b/c Thu Jan 01 00:00:01 1970 +0000
539 539 @@ -0,0 +1,2 @@
540 540 +$Id$
541 541 +tests for different changenodes
542 542
543 543 $ hg qpop
544 544 popping mqtest.diff
545 545 patch queue now empty
546 546
547 547 qgoto, implying qpush, should expand
548 548
549 549 $ hg qgoto mqtest.diff
550 550 applying mqtest.diff
551 551 now at: mqtest.diff
552 552 $ cat c
553 553 $Id: c,v 40a904bbbe4c 1970/01/01 00:00:01 user $
554 554 tests for different changenodes
555 555 $ hg cat c
556 556 $Id: c,v 40a904bbbe4c 1970/01/01 00:00:01 user $
557 557 tests for different changenodes
558 558
559 559 Keywords should not be expanded in filelog
560 560
561 561 $ hg --config 'extensions.keyword=!' cat c
562 562 $Id$
563 563 tests for different changenodes
564 564
565 565 qpop and move on
566 566
567 567 $ hg qpop
568 568 popping mqtest.diff
569 569 patch queue now empty
570 570
571 571 Copy and show added kwfiles
572 572
573 573 $ hg cp a c
574 574 $ hg kwfiles
575 575 a
576 576 c
577 577
578 578 Commit and show expansion in original and copy
579 579
580 580 $ hg --debug commit -ma2c -d '1 0' -u 'User Name <user@example.com>'
581 581 invalid branchheads cache (served): tip differs
582 582 c
583 583 c: copy a:0045e12f6c5791aac80ca6cbfd97709a88307292
584 584 invalid branchheads cache (served): tip differs
585 585 overwriting c expanding keywords
586 586 committed changeset 2:25736cf2f5cbe41f6be4e6784ef6ecf9f3bbcc7d
587 587 $ cat a c
588 588 expand $Id: a,v ef63ca68695b 1970/01/01 00:00:00 user $
589 589 do not process $Id:
590 590 xxx $
591 591 expand $Id: c,v 25736cf2f5cb 1970/01/01 00:00:01 user $
592 592 do not process $Id:
593 593 xxx $
594 594
595 595 Touch copied c and check its status
596 596
597 597 $ touch c
598 598 $ hg status
599 599
600 600 Copy kwfile to keyword ignored file unexpanding keywords
601 601
602 602 $ hg --verbose copy a i
603 603 copying a to i
604 604 overwriting i shrinking keywords
605 605 $ head -n 1 i
606 606 expand $Id$
607 607 $ hg forget i
608 608 $ rm i
609 609
610 610 Copy ignored file to ignored file: no overwriting
611 611
612 612 $ hg --verbose copy b i
613 613 copying b to i
614 614 $ hg forget i
615 615 $ rm i
616 616
617 617 cp symlink file; hg cp -A symlink file (part1)
618 618 - copied symlink points to kwfile: overwrite
619 619
620 620 #if symlink
621 621 $ cp sym i
622 622 $ ls -l i
623 623 -rw-r--r--* (glob)
624 624 $ head -1 i
625 625 expand $Id: a,v ef63ca68695b 1970/01/01 00:00:00 user $
626 626 $ hg copy --after --verbose sym i
627 627 copying sym to i
628 628 overwriting i shrinking keywords
629 629 $ head -1 i
630 630 expand $Id$
631 631 $ hg forget i
632 632 $ rm i
633 633 #endif
634 634
635 635 Test different options of hg kwfiles
636 636
637 637 $ hg kwfiles
638 638 a
639 639 c
640 640 $ hg -v kwfiles --ignore
641 641 I b
642 642 I sym
643 643 $ hg kwfiles --all
644 644 K a
645 645 K c
646 646 I b
647 647 I sym
648 648
649 649 Diff specific revision
650 650
651 651 $ hg diff --rev 1
652 652 diff -r ef63ca68695b c
653 653 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
654 654 +++ b/c * (glob)
655 655 @@ -0,0 +1,3 @@
656 656 +expand $Id$
657 657 +do not process $Id:
658 658 +xxx $
659 659
660 660 Status after rollback:
661 661
662 662 $ hg rollback
663 663 repository tip rolled back to revision 1 (undo commit)
664 664 working directory now based on revision 1
665 665 $ hg status
666 666 A c
667 667 $ hg update --clean
668 668 0 files updated, 0 files merged, 0 files removed, 0 files unresolved
669 669
670 670 #if symlink
671 671
672 672 cp symlink file; hg cp -A symlink file (part2)
673 673 - copied symlink points to kw ignored file: do not overwrite
674 674
675 675 $ cat a > i
676 676 $ ln -s i symignored
677 677 $ hg commit -Am 'fake expansion in ignored and symlink' i symignored
678 678 $ cp symignored x
679 679 $ hg copy --after --verbose symignored x
680 680 copying symignored to x
681 681 $ head -n 1 x
682 682 expand $Id: a,v ef63ca68695b 1970/01/01 00:00:00 user $
683 683 $ hg forget x
684 684 $ rm x
685 685
686 686 $ hg rollback
687 687 repository tip rolled back to revision 1 (undo commit)
688 688 working directory now based on revision 1
689 689 $ hg update --clean
690 690 0 files updated, 0 files merged, 0 files removed, 0 files unresolved
691 691 $ rm i symignored
692 692
693 693 #endif
694 694
695 695 Custom keywordmaps as argument to kwdemo
696 696
697 697 $ hg --quiet kwdemo "Xinfo = {author}: {desc}"
698 698 [extensions]
699 699 keyword =
700 700 [keyword]
701 701 ** =
702 702 b = ignore
703 703 demo.txt =
704 704 i = ignore
705 705 [keywordset]
706 706 svn = False
707 707 [keywordmaps]
708 708 Xinfo = {author}: {desc}
709 709 $Xinfo: test: hg keyword configuration and expansion example $
710 710
711 711 Configure custom keywordmaps
712 712
713 713 $ cat <<EOF >>$HGRCPATH
714 714 > [keywordmaps]
715 715 > Id = {file} {node|short} {date|rfc822date} {author|user}
716 716 > Xinfo = {author}: {desc}
717 717 > EOF
718 718
719 719 Cat and hg cat files before custom expansion
720 720
721 721 $ cat a b
722 722 expand $Id: a,v ef63ca68695b 1970/01/01 00:00:00 user $
723 723 do not process $Id:
724 724 xxx $
725 725 ignore $Id$
726 726 $ hg cat sym a b && echo
727 727 expand $Id: a ef63ca68695b Thu, 01 Jan 1970 00:00:00 +0000 user $
728 728 do not process $Id:
729 729 xxx $
730 730 ignore $Id$
731 731 a
732 732
733 733 Write custom keyword and prepare multi-line commit message
734 734
735 735 $ echo '$Xinfo$' >> a
736 736 $ cat <<EOF >> log
737 737 > firstline
738 738 > secondline
739 739 > EOF
740 740
741 741 Interrupted commit should not change state
742 742
743 743 $ hg commit
744 744 abort: empty commit message
745 745 [255]
746 746 $ hg status
747 747 M a
748 748 ? c
749 749 ? log
750 750
751 751 Commit with multi-line message and custom expansion
752 752
753 753 |Note:
754 754 |
755 755 | After the last rollback, the "served" branchheads cache became invalid, but
756 756 | all changesets in the repo were public. For filtering this means:
757 757 | "immutable" == "served" == ΓΈ.
758 758 |
759 759 | As the "served" cache is invalid, we fall back to the "immutable" cache. But
760 760 | no update is needed between "immutable" and "served" and the "served" cache
761 761 | is not updated on disk. The on-disk version therefore stays invalid for some
762 762 | time. This explains why the "served" branchheads cache is detected as
763 763 | invalid here.
764 764
765 765 $ hg --debug commit -l log -d '2 0' -u 'User Name <user@example.com>'
766 766 invalid branchheads cache (served): tip differs
767 767 a
768 768 invalid branchheads cache (served): tip differs
769 769 overwriting a expanding keywords
770 770 committed changeset 2:bb948857c743469b22bbf51f7ec8112279ca5d83
771 771 $ rm log
772 772
773 773 Stat, verify and show custom expansion (firstline)
774 774
775 775 $ hg status
776 776 ? c
777 777 $ hg verify
778 778 checking changesets
779 779 checking manifests
780 780 crosschecking files in changesets and manifests
781 781 checking files
782 782 3 files, 3 changesets, 4 total revisions
783 783 $ cat a b
784 784 expand $Id: a bb948857c743 Thu, 01 Jan 1970 00:00:02 +0000 user $
785 785 do not process $Id:
786 786 xxx $
787 787 $Xinfo: User Name <user@example.com>: firstline $
788 788 ignore $Id$
789 789 $ hg cat sym a b && echo
790 790 expand $Id: a bb948857c743 Thu, 01 Jan 1970 00:00:02 +0000 user $
791 791 do not process $Id:
792 792 xxx $
793 793 $Xinfo: User Name <user@example.com>: firstline $
794 794 ignore $Id$
795 795 a
796 796
797 797 annotate
798 798
799 799 $ hg annotate a
800 800 1: expand $Id$
801 801 1: do not process $Id:
802 802 1: xxx $
803 803 2: $Xinfo$
804 804
805 805 remove with status checks
806 806
807 807 $ hg debugrebuildstate
808 808 $ hg remove a
809 809 $ hg --debug commit -m rma
810 810 committed changeset 3:d14c712653769de926994cf7fbb06c8fbd68f012
811 811 $ hg status
812 812 ? c
813 813
814 814 Rollback, revert, and check expansion
815 815
816 816 $ hg rollback
817 817 repository tip rolled back to revision 2 (undo commit)
818 818 working directory now based on revision 2
819 819 $ hg status
820 820 R a
821 821 ? c
822 822 $ hg revert --no-backup --rev tip a
823 823 $ cat a
824 824 expand $Id: a bb948857c743 Thu, 01 Jan 1970 00:00:02 +0000 user $
825 825 do not process $Id:
826 826 xxx $
827 827 $Xinfo: User Name <user@example.com>: firstline $
828 828
829 829 Clone to test global and local configurations
830 830
831 831 $ cd ..
832 832
833 833 Expansion in destination with global configuration
834 834
835 835 $ hg --quiet clone Test globalconf
836 836 $ cat globalconf/a
837 837 expand $Id: a bb948857c743 Thu, 01 Jan 1970 00:00:02 +0000 user $
838 838 do not process $Id:
839 839 xxx $
840 840 $Xinfo: User Name <user@example.com>: firstline $
841 841
842 842 No expansion in destination with local configuration in origin only
843 843
844 844 $ hg --quiet --config 'keyword.**=ignore' clone Test localconf
845 845 $ cat localconf/a
846 846 expand $Id$
847 847 do not process $Id:
848 848 xxx $
849 849 $Xinfo$
850 850
851 851 Clone to test incoming
852 852
853 853 $ hg clone -r1 Test Test-a
854 854 adding changesets
855 855 adding manifests
856 856 adding file changes
857 857 added 2 changesets with 3 changes to 3 files
858 858 updating to branch default
859 859 3 files updated, 0 files merged, 0 files removed, 0 files unresolved
860 860 $ cd Test-a
861 861 $ cat <<EOF >> .hg/hgrc
862 862 > [paths]
863 863 > default = ../Test
864 864 > EOF
865 865 $ hg incoming
866 866 comparing with $TESTTMP/Test (glob)
867 867 searching for changes
868 868 changeset: 2:bb948857c743
869 869 tag: tip
870 870 user: User Name <user@example.com>
871 871 date: Thu Jan 01 00:00:02 1970 +0000
872 872 summary: firstline
873 873
874 874 Imported patch should not be rejected
875 875
876 876 >>> import re
877 877 >>> text = re.sub(r'(Id.*)', r'\1 rejecttest', open('a').read())
878 878 >>> open('a', 'wb').write(text)
879 879 $ hg --debug commit -m'rejects?' -d '3 0' -u 'User Name <user@example.com>'
880 880 a
881 881 overwriting a expanding keywords
882 882 committed changeset 2:85e279d709ffc28c9fdd1b868570985fc3d87082
883 883 $ hg export -o ../rejecttest.diff tip
884 884 $ cd ../Test
885 885 $ hg import ../rejecttest.diff
886 886 applying ../rejecttest.diff
887 887 $ cat a b
888 888 expand $Id: a 4e0994474d25 Thu, 01 Jan 1970 00:00:03 +0000 user $ rejecttest
889 889 do not process $Id: rejecttest
890 890 xxx $
891 891 $Xinfo: User Name <user@example.com>: rejects? $
892 892 ignore $Id$
893 893
894 894 $ hg rollback
895 895 repository tip rolled back to revision 2 (undo import)
896 896 working directory now based on revision 2
897 897 $ hg update --clean
898 898 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
899 899
900 900 kwexpand/kwshrink on selected files
901 901
902 902 $ mkdir x
903 903 $ hg copy a x/a
904 904 $ hg --verbose kwshrink a
905 905 overwriting a shrinking keywords
906 906 - sleep required for dirstate.normal() check
907 907 $ sleep 1
908 908 $ hg status a
909 909 $ hg --verbose kwexpand a
910 910 overwriting a expanding keywords
911 911 $ hg status a
912 912
913 913 kwexpand x/a should abort
914 914
915 915 $ hg --verbose kwexpand x/a
916 916 abort: outstanding uncommitted changes
917 917 [255]
918 918 $ cd x
919 919 $ hg --debug commit -m xa -d '3 0' -u 'User Name <user@example.com>'
920 920 x/a
921 921 x/a: copy a:779c764182ce5d43e2b1eb66ce06d7b47bfe342e
922 922 overwriting x/a expanding keywords
923 923 committed changeset 3:b4560182a3f9a358179fd2d835c15e9da379c1e4
924 924 $ cat a
925 925 expand $Id: x/a b4560182a3f9 Thu, 01 Jan 1970 00:00:03 +0000 user $
926 926 do not process $Id:
927 927 xxx $
928 928 $Xinfo: User Name <user@example.com>: xa $
929 929
930 930 kwshrink a inside directory x
931 931
932 932 $ hg --verbose kwshrink a
933 933 overwriting x/a shrinking keywords
934 934 $ cat a
935 935 expand $Id$
936 936 do not process $Id:
937 937 xxx $
938 938 $Xinfo$
939 939 $ cd ..
940 940
941 941 kwexpand nonexistent
942 942
943 943 $ hg kwexpand nonexistent
944 944 nonexistent:* (glob)
945 945
946 946
947 947 #if serve
948 948 hg serve
949 949 - expand with hgweb file
950 950 - no expansion with hgweb annotate/changeset/filediff
951 951 - check errors
952 952
953 953 $ hg serve -p $HGPORT -d --pid-file=hg.pid -A access.log -E errors.log
954 954 $ cat hg.pid >> $DAEMON_PIDS
955 955 $ "$TESTDIR/get-with-headers.py" localhost:$HGPORT 'file/tip/a/?style=raw'
956 956 200 Script output follows
957 957
958 958 expand $Id: a bb948857c743 Thu, 01 Jan 1970 00:00:02 +0000 user $
959 959 do not process $Id:
960 960 xxx $
961 961 $Xinfo: User Name <user@example.com>: firstline $
962 962 $ "$TESTDIR/get-with-headers.py" localhost:$HGPORT 'annotate/tip/a/?style=raw'
963 963 200 Script output follows
964 964
965 965
966 966 user@1: expand $Id$
967 967 user@1: do not process $Id:
968 968 user@1: xxx $
969 969 user@2: $Xinfo$
970 970
971 971
972 972
973 973
974 974 $ "$TESTDIR/get-with-headers.py" localhost:$HGPORT 'rev/tip/?style=raw'
975 975 200 Script output follows
976 976
977 977
978 978 # HG changeset patch
979 979 # User User Name <user@example.com>
980 980 # Date 3 0
981 981 # Node ID b4560182a3f9a358179fd2d835c15e9da379c1e4
982 982 # Parent bb948857c743469b22bbf51f7ec8112279ca5d83
983 983 xa
984 984
985 985 diff -r bb948857c743 -r b4560182a3f9 x/a
986 986 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
987 987 +++ b/x/a Thu Jan 01 00:00:03 1970 +0000
988 988 @@ -0,0 +1,4 @@
989 989 +expand $Id$
990 990 +do not process $Id:
991 991 +xxx $
992 992 +$Xinfo$
993 993
994 994 $ "$TESTDIR/get-with-headers.py" localhost:$HGPORT 'diff/bb948857c743/a?style=raw'
995 995 200 Script output follows
996 996
997 997
998 998 diff -r ef63ca68695b -r bb948857c743 a
999 999 --- a/a Thu Jan 01 00:00:00 1970 +0000
1000 1000 +++ b/a Thu Jan 01 00:00:02 1970 +0000
1001 1001 @@ -1,3 +1,4 @@
1002 1002 expand $Id$
1003 1003 do not process $Id:
1004 1004 xxx $
1005 1005 +$Xinfo$
1006 1006
1007 1007
1008 1008
1009 1009
1010 1010 $ cat errors.log
1011 1011 #endif
1012 1012
1013 1013 Prepare merge and resolve tests
1014 1014
1015 1015 $ echo '$Id$' > m
1016 1016 $ hg add m
1017 1017 $ hg commit -m 4kw
1018 1018 $ echo foo >> m
1019 1019 $ hg commit -m 5foo
1020 1020
1021 1021 simplemerge
1022 1022
1023 1023 $ hg update 4
1024 1024 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
1025 1025 $ echo foo >> m
1026 1026 $ hg commit -m 6foo
1027 1027 created new head
1028 1028 $ hg merge
1029 1029 0 files updated, 0 files merged, 0 files removed, 0 files unresolved
1030 1030 (branch merge, don't forget to commit)
1031 1031 $ hg commit -m simplemerge
1032 1032 $ cat m
1033 1033 $Id: m 27d48ee14f67 Thu, 01 Jan 1970 00:00:00 +0000 test $
1034 1034 foo
1035 1035
1036 1036 conflict: keyword should stay outside conflict zone
1037 1037
1038 1038 $ hg update 4
1039 1039 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
1040 1040 $ echo bar >> m
1041 1041 $ hg commit -m 8bar
1042 1042 created new head
1043 1043 $ hg merge
1044 1044 merging m
1045 1045 warning: conflicts during merge.
1046 1046 merging m incomplete! (edit conflicts, then use 'hg resolve --mark')
1047 1047 0 files updated, 0 files merged, 0 files removed, 1 files unresolved
1048 1048 use 'hg resolve' to retry unresolved file merges or 'hg update -C .' to abandon
1049 1049 [1]
1050 1050 $ cat m
1051 1051 $Id$
1052 1052 <<<<<<< local
1053 1053 bar
1054 1054 =======
1055 1055 foo
1056 1056 >>>>>>> other
1057 1057
1058 1058 resolve to local
1059 1059
1060 1060 $ HGMERGE=internal:local hg resolve -a
1061 no unresolved files; you may continue your unfinished operation
1061 no more unresolved files
1062 1062 $ hg commit -m localresolve
1063 1063 $ cat m
1064 1064 $Id: m 800511b3a22d Thu, 01 Jan 1970 00:00:00 +0000 test $
1065 1065 bar
1066 1066
1067 1067 Test restricted mode with transplant -b
1068 1068
1069 1069 $ hg update 6
1070 1070 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
1071 1071 $ hg branch foo
1072 1072 marked working directory as branch foo
1073 1073 (branches are permanent and global, did you want a bookmark?)
1074 1074 $ mv a a.bak
1075 1075 $ echo foobranch > a
1076 1076 $ cat a.bak >> a
1077 1077 $ rm a.bak
1078 1078 $ hg commit -m 9foobranch
1079 1079 $ hg update default
1080 1080 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
1081 1081 $ hg -y transplant -b foo tip
1082 1082 applying 4aa30d025d50
1083 1083 4aa30d025d50 transplanted to e00abbf63521
1084 1084
1085 1085 Expansion in changeset but not in file
1086 1086
1087 1087 $ hg tip -p
1088 1088 changeset: 11:e00abbf63521
1089 1089 tag: tip
1090 1090 parent: 9:800511b3a22d
1091 1091 user: test
1092 1092 date: Thu Jan 01 00:00:00 1970 +0000
1093 1093 summary: 9foobranch
1094 1094
1095 1095 diff -r 800511b3a22d -r e00abbf63521 a
1096 1096 --- a/a Thu Jan 01 00:00:00 1970 +0000
1097 1097 +++ b/a Thu Jan 01 00:00:00 1970 +0000
1098 1098 @@ -1,3 +1,4 @@
1099 1099 +foobranch
1100 1100 expand $Id$
1101 1101 do not process $Id:
1102 1102 xxx $
1103 1103
1104 1104 $ head -n 2 a
1105 1105 foobranch
1106 1106 expand $Id: a e00abbf63521 Thu, 01 Jan 1970 00:00:00 +0000 test $
1107 1107
1108 1108 Turn off expansion
1109 1109
1110 1110 $ hg -q rollback
1111 1111 $ hg -q update -C
1112 1112
1113 1113 kwshrink with unknown file u
1114 1114
1115 1115 $ cp a u
1116 1116 $ hg --verbose kwshrink
1117 1117 overwriting a shrinking keywords
1118 1118 overwriting m shrinking keywords
1119 1119 overwriting x/a shrinking keywords
1120 1120
1121 1121 Keywords shrunk in working directory, but not yet disabled
1122 1122 - cat shows unexpanded keywords
1123 1123 - hg cat shows expanded keywords
1124 1124
1125 1125 $ cat a b
1126 1126 expand $Id$
1127 1127 do not process $Id:
1128 1128 xxx $
1129 1129 $Xinfo$
1130 1130 ignore $Id$
1131 1131 $ hg cat sym a b && echo
1132 1132 expand $Id: a bb948857c743 Thu, 01 Jan 1970 00:00:02 +0000 user $
1133 1133 do not process $Id:
1134 1134 xxx $
1135 1135 $Xinfo: User Name <user@example.com>: firstline $
1136 1136 ignore $Id$
1137 1137 a
1138 1138
1139 1139 Now disable keyword expansion
1140 1140
1141 1141 $ rm "$HGRCPATH"
1142 1142 $ cat a b
1143 1143 expand $Id$
1144 1144 do not process $Id:
1145 1145 xxx $
1146 1146 $Xinfo$
1147 1147 ignore $Id$
1148 1148 $ hg cat sym a b && echo
1149 1149 expand $Id$
1150 1150 do not process $Id:
1151 1151 xxx $
1152 1152 $Xinfo$
1153 1153 ignore $Id$
1154 1154 a
1155 1155
1156 1156 $ cd ..
@@ -1,350 +1,350 b''
1 1 $ USERCACHE="$TESTTMP/cache"; export USERCACHE
2 2 $ mkdir "${USERCACHE}"
3 3 $ cat >> $HGRCPATH <<EOF
4 4 > [extensions]
5 5 > largefiles =
6 6 > share =
7 7 > strip =
8 8 > convert =
9 9 > [largefiles]
10 10 > minsize = 0.5
11 11 > patterns = **.other
12 12 > **.dat
13 13 > usercache=${USERCACHE}
14 14 > EOF
15 15
16 16 "lfconvert" works
17 17 $ hg init bigfile-repo
18 18 $ cd bigfile-repo
19 19 $ cat >> .hg/hgrc <<EOF
20 20 > [extensions]
21 21 > largefiles = !
22 22 > EOF
23 23 $ mkdir sub
24 24 $ dd if=/dev/zero bs=1k count=256 > large 2> /dev/null
25 25 $ dd if=/dev/zero bs=1k count=256 > large2 2> /dev/null
26 26 $ echo normal > normal1
27 27 $ echo alsonormal > sub/normal2
28 28 $ dd if=/dev/zero bs=1k count=10 > sub/maybelarge.dat 2> /dev/null
29 29 $ hg addremove
30 30 adding large
31 31 adding large2
32 32 adding normal1
33 33 adding sub/maybelarge.dat
34 34 adding sub/normal2
35 35 $ hg commit -m"add large, normal1" large normal1
36 36 $ hg commit -m"add sub/*" sub
37 37
38 38 Test tag parsing
39 39 $ cat >> .hgtags <<EOF
40 40 > IncorrectlyFormattedTag!
41 41 > invalidhash sometag
42 42 > 0123456789abcdef anothertag
43 43 > EOF
44 44 $ hg add .hgtags
45 45 $ hg commit -m"add large2" large2 .hgtags
46 46
47 47 Test link+rename largefile codepath
48 48 $ [ -d .hg/largefiles ] && echo fail || echo pass
49 49 pass
50 50 $ cd ..
51 51 $ hg lfconvert --size 0.2 bigfile-repo largefiles-repo
52 52 initializing destination largefiles-repo
53 53 skipping incorrectly formatted tag IncorrectlyFormattedTag!
54 54 skipping incorrectly formatted id invalidhash
55 55 no mapping for id 0123456789abcdef
56 56 #if symlink
57 57 $ hg --cwd bigfile-repo rename large2 large3
58 58 $ ln -sf large bigfile-repo/large3
59 59 $ hg --cwd bigfile-repo commit -m"make large2 a symlink" large2 large3
60 60 $ hg lfconvert --size 0.2 bigfile-repo largefiles-repo-symlink
61 61 initializing destination largefiles-repo-symlink
62 62 skipping incorrectly formatted tag IncorrectlyFormattedTag!
63 63 skipping incorrectly formatted id invalidhash
64 64 no mapping for id 0123456789abcdef
65 65 abort: renamed/copied largefile large3 becomes symlink
66 66 [255]
67 67 #endif
68 68 $ cd bigfile-repo
69 69 $ hg strip --no-backup 2
70 70 0 files updated, 0 files merged, 2 files removed, 0 files unresolved
71 71 $ cd ..
72 72 $ rm -rf largefiles-repo largefiles-repo-symlink
73 73
74 74 $ hg lfconvert --size 0.2 bigfile-repo largefiles-repo
75 75 initializing destination largefiles-repo
76 76
77 77 "lfconvert" converts content correctly
78 78 $ cd largefiles-repo
79 79 $ hg up
80 80 getting changed largefiles
81 81 2 largefiles updated, 0 removed
82 82 4 files updated, 0 files merged, 0 files removed, 0 files unresolved
83 83 $ hg locate
84 84 .hglf/large
85 85 .hglf/sub/maybelarge.dat
86 86 normal1
87 87 sub/normal2
88 88 $ cat normal1
89 89 normal
90 90 $ cat sub/normal2
91 91 alsonormal
92 92 $ "$TESTDIR/md5sum.py" large sub/maybelarge.dat
93 93 ec87a838931d4d5d2e94a04644788a55 large
94 94 1276481102f218c981e0324180bafd9f sub/maybelarge.dat
95 95
96 96 "lfconvert" adds 'largefiles' to .hg/requires.
97 97 $ cat .hg/requires
98 98 dotencode
99 99 fncache
100 100 largefiles
101 101 revlogv1
102 102 store
103 103
104 104 "lfconvert" includes a newline at the end of the standin files.
105 105 $ cat .hglf/large .hglf/sub/maybelarge.dat
106 106 2e000fa7e85759c7f4c254d4d9c33ef481e459a7
107 107 34e163be8e43c5631d8b92e9c43ab0bf0fa62b9c
108 108 $ cd ..
109 109
110 110 add some changesets to rename/remove/merge
111 111 $ cd bigfile-repo
112 112 $ hg mv -q sub stuff
113 113 $ hg commit -m"rename sub/ to stuff/"
114 114 $ hg update -q 1
115 115 $ echo blah >> normal3
116 116 $ echo blah >> sub/normal2
117 117 $ echo blah >> sub/maybelarge.dat
118 118 $ "$TESTDIR/md5sum.py" sub/maybelarge.dat
119 119 1dd0b99ff80e19cff409702a1d3f5e15 sub/maybelarge.dat
120 120 $ hg commit -A -m"add normal3, modify sub/*"
121 121 adding normal3
122 122 created new head
123 123 $ hg rm large normal3
124 124 $ hg commit -q -m"remove large, normal3"
125 125 $ hg merge
126 126 merging sub/maybelarge.dat and stuff/maybelarge.dat to stuff/maybelarge.dat
127 127 warning: $TESTTMP/bigfile-repo/stuff/maybelarge.dat looks like a binary file. (glob)
128 128 merging stuff/maybelarge.dat incomplete! (edit conflicts, then use 'hg resolve --mark')
129 129 merging sub/normal2 and stuff/normal2 to stuff/normal2
130 130 0 files updated, 1 files merged, 0 files removed, 1 files unresolved
131 131 use 'hg resolve' to retry unresolved file merges or 'hg update -C .' to abandon
132 132 [1]
133 133 $ hg cat -r . sub/maybelarge.dat > stuff/maybelarge.dat
134 134 $ hg resolve -m stuff/maybelarge.dat
135 no unresolved files; you may continue your unfinished operation
135 no more unresolved files
136 136 $ hg commit -m"merge"
137 137 $ hg log -G --template "{rev}:{node|short} {desc|firstline}\n"
138 138 @ 5:4884f215abda merge
139 139 |\
140 140 | o 4:7285f817b77e remove large, normal3
141 141 | |
142 142 | o 3:67e3892e3534 add normal3, modify sub/*
143 143 | |
144 144 o | 2:c96c8beb5d56 rename sub/ to stuff/
145 145 |/
146 146 o 1:020c65d24e11 add sub/*
147 147 |
148 148 o 0:117b8328f97a add large, normal1
149 149
150 150 $ cd ..
151 151
152 152 lfconvert with rename, merge, and remove
153 153 $ rm -rf largefiles-repo
154 154 $ hg lfconvert --size 0.2 bigfile-repo largefiles-repo
155 155 initializing destination largefiles-repo
156 156 $ cd largefiles-repo
157 157 $ hg log -G --template "{rev}:{node|short} {desc|firstline}\n"
158 158 o 5:8e05f5f2b77e merge
159 159 |\
160 160 | o 4:a5a02de7a8e4 remove large, normal3
161 161 | |
162 162 | o 3:55759520c76f add normal3, modify sub/*
163 163 | |
164 164 o | 2:261ad3f3f037 rename sub/ to stuff/
165 165 |/
166 166 o 1:334e5237836d add sub/*
167 167 |
168 168 o 0:d4892ec57ce2 add large, normal1
169 169
170 170 $ hg locate -r 2
171 171 .hglf/large
172 172 .hglf/stuff/maybelarge.dat
173 173 normal1
174 174 stuff/normal2
175 175 $ hg locate -r 3
176 176 .hglf/large
177 177 .hglf/sub/maybelarge.dat
178 178 normal1
179 179 normal3
180 180 sub/normal2
181 181 $ hg locate -r 4
182 182 .hglf/sub/maybelarge.dat
183 183 normal1
184 184 sub/normal2
185 185 $ hg locate -r 5
186 186 .hglf/stuff/maybelarge.dat
187 187 normal1
188 188 stuff/normal2
189 189 $ hg update
190 190 getting changed largefiles
191 191 1 largefiles updated, 0 removed
192 192 3 files updated, 0 files merged, 0 files removed, 0 files unresolved
193 193 $ cat stuff/normal2
194 194 alsonormal
195 195 blah
196 196 $ "$TESTDIR/md5sum.py" stuff/maybelarge.dat
197 197 1dd0b99ff80e19cff409702a1d3f5e15 stuff/maybelarge.dat
198 198 $ cat .hglf/stuff/maybelarge.dat
199 199 76236b6a2c6102826c61af4297dd738fb3b1de38
200 200 $ cd ..
201 201
202 202 "lfconvert" error cases
203 203 $ hg lfconvert http://localhost/foo foo
204 204 abort: http://localhost/foo is not a local Mercurial repo
205 205 [255]
206 206 $ hg lfconvert foo ssh://localhost/foo
207 207 abort: ssh://localhost/foo is not a local Mercurial repo
208 208 [255]
209 209 $ hg lfconvert nosuchrepo foo
210 210 abort: repository nosuchrepo not found!
211 211 [255]
212 212 $ hg share -q -U bigfile-repo shared
213 213 $ printf 'bogus' > shared/.hg/sharedpath
214 214 $ hg lfconvert shared foo
215 215 abort: .hg/sharedpath points to nonexistent directory $TESTTMP/bogus! (glob)
216 216 [255]
217 217 $ hg lfconvert bigfile-repo largefiles-repo
218 218 initializing destination largefiles-repo
219 219 abort: repository largefiles-repo already exists!
220 220 [255]
221 221
222 222 add another largefile to the new largefiles repo
223 223 $ cd largefiles-repo
224 224 $ dd if=/dev/zero bs=1k count=1k > anotherlarge 2> /dev/null
225 225 $ hg add --lfsize=1 anotherlarge
226 226 $ hg commit -m "add anotherlarge (should be a largefile)"
227 227 $ cat .hglf/anotherlarge
228 228 3b71f43ff30f4b15b5cd85dd9e95ebc7e84eb5a3
229 229 $ cd ..
230 230
231 231 round-trip: converting back to a normal (non-largefiles) repo with
232 232 "lfconvert --to-normal" should give the same as ../bigfile-repo
233 233 $ cd largefiles-repo
234 234 $ hg lfconvert --to-normal . ../normal-repo
235 235 initializing destination ../normal-repo
236 236 $ cd ../normal-repo
237 237 $ cat >> .hg/hgrc <<EOF
238 238 > [extensions]
239 239 > largefiles = !
240 240 > EOF
241 241
242 242 # Hmmm: the changeset ID for rev 5 is different from the original
243 243 # normal repo (../bigfile-repo), because the changelog filelist
244 244 # differs between the two incarnations of rev 5: this repo includes
245 245 # 'large' in the list, but ../bigfile-repo does not. Since rev 5
246 246 # removes 'large' relative to the first parent in both repos, it seems
247 247 # to me that lfconvert is doing a *better* job than
248 248 # "hg remove" + "hg merge" + "hg commit".
249 249 # $ hg -R ../bigfile-repo debugdata -c 5
250 250 # $ hg debugdata -c 5
251 251 $ hg log -G --template "{rev}:{node|short} {desc|firstline}\n"
252 252 o 6:1635824e6f59 add anotherlarge (should be a largefile)
253 253 |
254 254 o 5:7215f8deeaaf merge
255 255 |\
256 256 | o 4:7285f817b77e remove large, normal3
257 257 | |
258 258 | o 3:67e3892e3534 add normal3, modify sub/*
259 259 | |
260 260 o | 2:c96c8beb5d56 rename sub/ to stuff/
261 261 |/
262 262 o 1:020c65d24e11 add sub/*
263 263 |
264 264 o 0:117b8328f97a add large, normal1
265 265
266 266 $ hg update
267 267 4 files updated, 0 files merged, 0 files removed, 0 files unresolved
268 268 $ hg locate
269 269 anotherlarge
270 270 normal1
271 271 stuff/maybelarge.dat
272 272 stuff/normal2
273 273 $ [ -d .hg/largefiles ] && echo fail || echo pass
274 274 pass
275 275
276 276 $ cd ..
277 277
278 278 Clearing the usercache ensures that commitctx doesn't try to cache largefiles
279 279 from the working dir on a convert.
280 280 $ rm "${USERCACHE}"/*
281 281 $ hg convert largefiles-repo
282 282 assuming destination largefiles-repo-hg
283 283 initializing destination largefiles-repo-hg repository
284 284 scanning source...
285 285 sorting...
286 286 converting...
287 287 6 add large, normal1
288 288 5 add sub/*
289 289 4 rename sub/ to stuff/
290 290 3 add normal3, modify sub/*
291 291 2 remove large, normal3
292 292 1 merge
293 293 0 add anotherlarge (should be a largefile)
294 294
295 295 $ hg -R largefiles-repo-hg log -G --template "{rev}:{node|short} {desc|firstline}\n"
296 296 o 6:17126745edfd add anotherlarge (should be a largefile)
297 297 |
298 298 o 5:9cc5aa7204f0 merge
299 299 |\
300 300 | o 4:a5a02de7a8e4 remove large, normal3
301 301 | |
302 302 | o 3:55759520c76f add normal3, modify sub/*
303 303 | |
304 304 o | 2:261ad3f3f037 rename sub/ to stuff/
305 305 |/
306 306 o 1:334e5237836d add sub/*
307 307 |
308 308 o 0:d4892ec57ce2 add large, normal1
309 309
310 310 Verify will fail (for now) if the usercache is purged before converting, since
311 311 largefiles are not cached in the converted repo's local store by the conversion
312 312 process.
313 313 $ hg -R largefiles-repo-hg verify --large --lfa
314 314 checking changesets
315 315 checking manifests
316 316 crosschecking files in changesets and manifests
317 317 checking files
318 318 8 files, 7 changesets, 12 total revisions
319 319 searching 7 changesets for largefiles
320 320 changeset 0:d4892ec57ce2: large references missing $TESTTMP/largefiles-repo-hg/.hg/largefiles/2e000fa7e85759c7f4c254d4d9c33ef481e459a7 (glob)
321 321 changeset 1:334e5237836d: sub/maybelarge.dat references missing $TESTTMP/largefiles-repo-hg/.hg/largefiles/34e163be8e43c5631d8b92e9c43ab0bf0fa62b9c (glob)
322 322 changeset 2:261ad3f3f037: stuff/maybelarge.dat references missing $TESTTMP/largefiles-repo-hg/.hg/largefiles/34e163be8e43c5631d8b92e9c43ab0bf0fa62b9c (glob)
323 323 changeset 3:55759520c76f: sub/maybelarge.dat references missing $TESTTMP/largefiles-repo-hg/.hg/largefiles/76236b6a2c6102826c61af4297dd738fb3b1de38 (glob)
324 324 changeset 5:9cc5aa7204f0: stuff/maybelarge.dat references missing $TESTTMP/largefiles-repo-hg/.hg/largefiles/76236b6a2c6102826c61af4297dd738fb3b1de38 (glob)
325 325 changeset 6:17126745edfd: anotherlarge references missing $TESTTMP/largefiles-repo-hg/.hg/largefiles/3b71f43ff30f4b15b5cd85dd9e95ebc7e84eb5a3 (glob)
326 326 verified existence of 6 revisions of 4 largefiles
327 327 [1]
328 328 $ hg -R largefiles-repo-hg showconfig paths
329 329
330 330
331 331 Avoid a traceback if a largefile isn't available (issue3519)
332 332
333 333 Ensure the largefile can be cached in the source if necessary
334 334 $ hg clone -U largefiles-repo issue3519
335 335 $ rm -f "${USERCACHE}"/*
336 336 $ hg lfconvert --to-normal issue3519 normalized3519
337 337 initializing destination normalized3519
338 338
339 339 Ensure the abort message is useful if a largefile is entirely unavailable
340 340 $ rm -rf normalized3519
341 341 $ rm "${USERCACHE}"/*
342 342 $ rm issue3519/.hg/largefiles/*
343 343 $ rm largefiles-repo/.hg/largefiles/*
344 344 $ hg lfconvert --to-normal issue3519 normalized3519
345 345 initializing destination normalized3519
346 346 large: largefile 2e000fa7e85759c7f4c254d4d9c33ef481e459a7 not available from file:/*/$TESTTMP/largefiles-repo (glob)
347 347 abort: missing largefile 'large' from revision d4892ec57ce212905215fad1d9018f56b99202ad
348 348 [255]
349 349
350 350
@@ -1,1377 +1,1377 b''
1 1 Log on empty repository: checking consistency
2 2
3 3 $ hg init empty
4 4 $ cd empty
5 5 $ hg log
6 6 $ hg log -r 1
7 7 abort: unknown revision '1'!
8 8 [255]
9 9 $ hg log -r -1:0
10 10 abort: unknown revision '-1'!
11 11 [255]
12 12 $ hg log -r 'branch(name)'
13 13 abort: unknown revision 'name'!
14 14 [255]
15 15 $ hg log -r null -q
16 16 -1:000000000000
17 17
18 18 The g is crafted to have 2 filelog topological heads in a linear
19 19 changeset graph
20 20
21 21 $ hg init a
22 22 $ cd a
23 23 $ echo a > a
24 24 $ echo f > f
25 25 $ hg ci -Ama -d '1 0'
26 26 adding a
27 27 adding f
28 28
29 29 $ hg cp a b
30 30 $ hg cp f g
31 31 $ hg ci -mb -d '2 0'
32 32
33 33 $ mkdir dir
34 34 $ hg mv b dir
35 35 $ echo g >> g
36 36 $ echo f >> f
37 37 $ hg ci -mc -d '3 0'
38 38
39 39 $ hg mv a b
40 40 $ hg cp -f f g
41 41 $ echo a > d
42 42 $ hg add d
43 43 $ hg ci -md -d '4 0'
44 44
45 45 $ hg mv dir/b e
46 46 $ hg ci -me -d '5 0'
47 47
48 48 $ hg log a
49 49 changeset: 0:9161b9aeaf16
50 50 user: test
51 51 date: Thu Jan 01 00:00:01 1970 +0000
52 52 summary: a
53 53
54 54 log on directory
55 55
56 56 $ hg log dir
57 57 changeset: 4:7e4639b4691b
58 58 tag: tip
59 59 user: test
60 60 date: Thu Jan 01 00:00:05 1970 +0000
61 61 summary: e
62 62
63 63 changeset: 2:f8954cd4dc1f
64 64 user: test
65 65 date: Thu Jan 01 00:00:03 1970 +0000
66 66 summary: c
67 67
68 68 $ hg log somethingthatdoesntexist dir
69 69 changeset: 4:7e4639b4691b
70 70 tag: tip
71 71 user: test
72 72 date: Thu Jan 01 00:00:05 1970 +0000
73 73 summary: e
74 74
75 75 changeset: 2:f8954cd4dc1f
76 76 user: test
77 77 date: Thu Jan 01 00:00:03 1970 +0000
78 78 summary: c
79 79
80 80
81 81 -f, directory
82 82
83 83 $ hg log -f dir
84 84 abort: cannot follow file not in parent revision: "dir"
85 85 [255]
86 86
87 87 -f, a wrong style
88 88
89 89 $ hg log -f -l1 --style something
90 90 abort: style 'something' not found
91 91 (available styles: bisect, changelog, compact, default, phases, xml)
92 92 [255]
93 93
94 94 -f, phases style
95 95
96 96
97 97 $ hg log -f -l1 --style phases
98 98 changeset: 4:7e4639b4691b
99 99 tag: tip
100 100 phase: draft
101 101 user: test
102 102 date: Thu Jan 01 00:00:05 1970 +0000
103 103 summary: e
104 104
105 105
106 106 -f, but no args
107 107
108 108 $ hg log -f
109 109 changeset: 4:7e4639b4691b
110 110 tag: tip
111 111 user: test
112 112 date: Thu Jan 01 00:00:05 1970 +0000
113 113 summary: e
114 114
115 115 changeset: 3:2ca5ba701980
116 116 user: test
117 117 date: Thu Jan 01 00:00:04 1970 +0000
118 118 summary: d
119 119
120 120 changeset: 2:f8954cd4dc1f
121 121 user: test
122 122 date: Thu Jan 01 00:00:03 1970 +0000
123 123 summary: c
124 124
125 125 changeset: 1:d89b0a12d229
126 126 user: test
127 127 date: Thu Jan 01 00:00:02 1970 +0000
128 128 summary: b
129 129
130 130 changeset: 0:9161b9aeaf16
131 131 user: test
132 132 date: Thu Jan 01 00:00:01 1970 +0000
133 133 summary: a
134 134
135 135
136 136 one rename
137 137
138 138 $ hg up -q 2
139 139 $ hg log -vf a
140 140 changeset: 0:9161b9aeaf16
141 141 user: test
142 142 date: Thu Jan 01 00:00:01 1970 +0000
143 143 files: a f
144 144 description:
145 145 a
146 146
147 147
148 148
149 149 many renames
150 150
151 151 $ hg up -q tip
152 152 $ hg log -vf e
153 153 changeset: 4:7e4639b4691b
154 154 tag: tip
155 155 user: test
156 156 date: Thu Jan 01 00:00:05 1970 +0000
157 157 files: dir/b e
158 158 description:
159 159 e
160 160
161 161
162 162 changeset: 2:f8954cd4dc1f
163 163 user: test
164 164 date: Thu Jan 01 00:00:03 1970 +0000
165 165 files: b dir/b f g
166 166 description:
167 167 c
168 168
169 169
170 170 changeset: 1:d89b0a12d229
171 171 user: test
172 172 date: Thu Jan 01 00:00:02 1970 +0000
173 173 files: b g
174 174 description:
175 175 b
176 176
177 177
178 178 changeset: 0:9161b9aeaf16
179 179 user: test
180 180 date: Thu Jan 01 00:00:01 1970 +0000
181 181 files: a f
182 182 description:
183 183 a
184 184
185 185
186 186
187 187
188 188 log -pf dir/b
189 189
190 190 $ hg up -q 3
191 191 $ hg log -pf dir/b
192 192 changeset: 2:f8954cd4dc1f
193 193 user: test
194 194 date: Thu Jan 01 00:00:03 1970 +0000
195 195 summary: c
196 196
197 197 diff -r d89b0a12d229 -r f8954cd4dc1f dir/b
198 198 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
199 199 +++ b/dir/b Thu Jan 01 00:00:03 1970 +0000
200 200 @@ -0,0 +1,1 @@
201 201 +a
202 202
203 203 changeset: 1:d89b0a12d229
204 204 user: test
205 205 date: Thu Jan 01 00:00:02 1970 +0000
206 206 summary: b
207 207
208 208 diff -r 9161b9aeaf16 -r d89b0a12d229 b
209 209 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
210 210 +++ b/b Thu Jan 01 00:00:02 1970 +0000
211 211 @@ -0,0 +1,1 @@
212 212 +a
213 213
214 214 changeset: 0:9161b9aeaf16
215 215 user: test
216 216 date: Thu Jan 01 00:00:01 1970 +0000
217 217 summary: a
218 218
219 219 diff -r 000000000000 -r 9161b9aeaf16 a
220 220 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
221 221 +++ b/a Thu Jan 01 00:00:01 1970 +0000
222 222 @@ -0,0 +1,1 @@
223 223 +a
224 224
225 225
226 226 log -vf dir/b
227 227
228 228 $ hg log -vf dir/b
229 229 changeset: 2:f8954cd4dc1f
230 230 user: test
231 231 date: Thu Jan 01 00:00:03 1970 +0000
232 232 files: b dir/b f g
233 233 description:
234 234 c
235 235
236 236
237 237 changeset: 1:d89b0a12d229
238 238 user: test
239 239 date: Thu Jan 01 00:00:02 1970 +0000
240 240 files: b g
241 241 description:
242 242 b
243 243
244 244
245 245 changeset: 0:9161b9aeaf16
246 246 user: test
247 247 date: Thu Jan 01 00:00:01 1970 +0000
248 248 files: a f
249 249 description:
250 250 a
251 251
252 252
253 253
254 254
255 255 -f and multiple filelog heads
256 256
257 257 $ hg up -q 2
258 258 $ hg log -f g --template '{rev}\n'
259 259 2
260 260 1
261 261 0
262 262 $ hg up -q tip
263 263 $ hg log -f g --template '{rev}\n'
264 264 3
265 265 2
266 266 0
267 267
268 268
269 269 log copies with --copies
270 270
271 271 $ hg log -vC --template '{rev} {file_copies}\n'
272 272 4 e (dir/b)
273 273 3 b (a)g (f)
274 274 2 dir/b (b)
275 275 1 b (a)g (f)
276 276 0
277 277
278 278 log copies switch without --copies, with old filecopy template
279 279
280 280 $ hg log -v --template '{rev} {file_copies_switch%filecopy}\n'
281 281 4
282 282 3
283 283 2
284 284 1
285 285 0
286 286
287 287 log copies switch with --copies
288 288
289 289 $ hg log -vC --template '{rev} {file_copies_switch}\n'
290 290 4 e (dir/b)
291 291 3 b (a)g (f)
292 292 2 dir/b (b)
293 293 1 b (a)g (f)
294 294 0
295 295
296 296
297 297 log copies with hardcoded style and with --style=default
298 298
299 299 $ hg log -vC -r4
300 300 changeset: 4:7e4639b4691b
301 301 tag: tip
302 302 user: test
303 303 date: Thu Jan 01 00:00:05 1970 +0000
304 304 files: dir/b e
305 305 copies: e (dir/b)
306 306 description:
307 307 e
308 308
309 309
310 310 $ hg log -vC -r4 --style=default
311 311 changeset: 4:7e4639b4691b
312 312 tag: tip
313 313 user: test
314 314 date: Thu Jan 01 00:00:05 1970 +0000
315 315 files: dir/b e
316 316 copies: e (dir/b)
317 317 description:
318 318 e
319 319
320 320
321 321
322 322
323 323 log copies, non-linear manifest
324 324
325 325 $ hg up -C 3
326 326 1 files updated, 0 files merged, 1 files removed, 0 files unresolved
327 327 $ hg mv dir/b e
328 328 $ echo foo > foo
329 329 $ hg ci -Ame2 -d '6 0'
330 330 adding foo
331 331 created new head
332 332 $ hg log -v --template '{rev} {file_copies}\n' -r 5
333 333 5 e (dir/b)
334 334
335 335
336 336 log copies, execute bit set
337 337
338 338 #if execbit
339 339 $ chmod +x e
340 340 $ hg ci -me3 -d '7 0'
341 341 $ hg log -v --template '{rev} {file_copies}\n' -r 6
342 342 6
343 343 #endif
344 344
345 345
346 346 log -p d
347 347
348 348 $ hg log -pv d
349 349 changeset: 3:2ca5ba701980
350 350 user: test
351 351 date: Thu Jan 01 00:00:04 1970 +0000
352 352 files: a b d g
353 353 description:
354 354 d
355 355
356 356
357 357 diff -r f8954cd4dc1f -r 2ca5ba701980 d
358 358 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
359 359 +++ b/d Thu Jan 01 00:00:04 1970 +0000
360 360 @@ -0,0 +1,1 @@
361 361 +a
362 362
363 363
364 364
365 365 log --removed file
366 366
367 367 $ hg log --removed -v a
368 368 changeset: 3:2ca5ba701980
369 369 user: test
370 370 date: Thu Jan 01 00:00:04 1970 +0000
371 371 files: a b d g
372 372 description:
373 373 d
374 374
375 375
376 376 changeset: 0:9161b9aeaf16
377 377 user: test
378 378 date: Thu Jan 01 00:00:01 1970 +0000
379 379 files: a f
380 380 description:
381 381 a
382 382
383 383
384 384
385 385 log --removed revrange file
386 386
387 387 $ hg log --removed -v -r0:2 a
388 388 changeset: 0:9161b9aeaf16
389 389 user: test
390 390 date: Thu Jan 01 00:00:01 1970 +0000
391 391 files: a f
392 392 description:
393 393 a
394 394
395 395
396 396 $ cd ..
397 397
398 398 log --follow tests
399 399
400 400 $ hg init follow
401 401 $ cd follow
402 402
403 403 $ echo base > base
404 404 $ hg ci -Ambase -d '1 0'
405 405 adding base
406 406
407 407 $ echo r1 >> base
408 408 $ hg ci -Amr1 -d '1 0'
409 409 $ echo r2 >> base
410 410 $ hg ci -Amr2 -d '1 0'
411 411
412 412 $ hg up -C 1
413 413 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
414 414 $ echo b1 > b1
415 415 $ hg ci -Amb1 -d '1 0'
416 416 adding b1
417 417 created new head
418 418
419 419
420 420 log -f
421 421
422 422 $ hg log -f
423 423 changeset: 3:e62f78d544b4
424 424 tag: tip
425 425 parent: 1:3d5bf5654eda
426 426 user: test
427 427 date: Thu Jan 01 00:00:01 1970 +0000
428 428 summary: b1
429 429
430 430 changeset: 1:3d5bf5654eda
431 431 user: test
432 432 date: Thu Jan 01 00:00:01 1970 +0000
433 433 summary: r1
434 434
435 435 changeset: 0:67e992f2c4f3
436 436 user: test
437 437 date: Thu Jan 01 00:00:01 1970 +0000
438 438 summary: base
439 439
440 440
441 441
442 442 log -f -r 1:tip
443 443
444 444 $ hg up -C 0
445 445 1 files updated, 0 files merged, 1 files removed, 0 files unresolved
446 446 $ echo b2 > b2
447 447 $ hg ci -Amb2 -d '1 0'
448 448 adding b2
449 449 created new head
450 450 $ hg log -f -r 1:tip
451 451 changeset: 1:3d5bf5654eda
452 452 user: test
453 453 date: Thu Jan 01 00:00:01 1970 +0000
454 454 summary: r1
455 455
456 456 changeset: 2:60c670bf5b30
457 457 user: test
458 458 date: Thu Jan 01 00:00:01 1970 +0000
459 459 summary: r2
460 460
461 461 changeset: 3:e62f78d544b4
462 462 parent: 1:3d5bf5654eda
463 463 user: test
464 464 date: Thu Jan 01 00:00:01 1970 +0000
465 465 summary: b1
466 466
467 467
468 468
469 469 log -r . with two parents
470 470
471 471 $ hg up -C 3
472 472 2 files updated, 0 files merged, 1 files removed, 0 files unresolved
473 473 $ hg merge tip
474 474 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
475 475 (branch merge, don't forget to commit)
476 476 $ hg log -r .
477 477 changeset: 3:e62f78d544b4
478 478 parent: 1:3d5bf5654eda
479 479 user: test
480 480 date: Thu Jan 01 00:00:01 1970 +0000
481 481 summary: b1
482 482
483 483
484 484
485 485 log -r . with one parent
486 486
487 487 $ hg ci -mm12 -d '1 0'
488 488 $ hg log -r .
489 489 changeset: 5:302e9dd6890d
490 490 tag: tip
491 491 parent: 3:e62f78d544b4
492 492 parent: 4:ddb82e70d1a1
493 493 user: test
494 494 date: Thu Jan 01 00:00:01 1970 +0000
495 495 summary: m12
496 496
497 497
498 498 $ echo postm >> b1
499 499 $ hg ci -Amb1.1 -d'1 0'
500 500
501 501
502 502 log --follow-first
503 503
504 504 $ hg log --follow-first
505 505 changeset: 6:2404bbcab562
506 506 tag: tip
507 507 user: test
508 508 date: Thu Jan 01 00:00:01 1970 +0000
509 509 summary: b1.1
510 510
511 511 changeset: 5:302e9dd6890d
512 512 parent: 3:e62f78d544b4
513 513 parent: 4:ddb82e70d1a1
514 514 user: test
515 515 date: Thu Jan 01 00:00:01 1970 +0000
516 516 summary: m12
517 517
518 518 changeset: 3:e62f78d544b4
519 519 parent: 1:3d5bf5654eda
520 520 user: test
521 521 date: Thu Jan 01 00:00:01 1970 +0000
522 522 summary: b1
523 523
524 524 changeset: 1:3d5bf5654eda
525 525 user: test
526 526 date: Thu Jan 01 00:00:01 1970 +0000
527 527 summary: r1
528 528
529 529 changeset: 0:67e992f2c4f3
530 530 user: test
531 531 date: Thu Jan 01 00:00:01 1970 +0000
532 532 summary: base
533 533
534 534
535 535
536 536 log -P 2
537 537
538 538 $ hg log -P 2
539 539 changeset: 6:2404bbcab562
540 540 tag: tip
541 541 user: test
542 542 date: Thu Jan 01 00:00:01 1970 +0000
543 543 summary: b1.1
544 544
545 545 changeset: 5:302e9dd6890d
546 546 parent: 3:e62f78d544b4
547 547 parent: 4:ddb82e70d1a1
548 548 user: test
549 549 date: Thu Jan 01 00:00:01 1970 +0000
550 550 summary: m12
551 551
552 552 changeset: 4:ddb82e70d1a1
553 553 parent: 0:67e992f2c4f3
554 554 user: test
555 555 date: Thu Jan 01 00:00:01 1970 +0000
556 556 summary: b2
557 557
558 558 changeset: 3:e62f78d544b4
559 559 parent: 1:3d5bf5654eda
560 560 user: test
561 561 date: Thu Jan 01 00:00:01 1970 +0000
562 562 summary: b1
563 563
564 564
565 565
566 566 log -r tip -p --git
567 567
568 568 $ hg log -r tip -p --git
569 569 changeset: 6:2404bbcab562
570 570 tag: tip
571 571 user: test
572 572 date: Thu Jan 01 00:00:01 1970 +0000
573 573 summary: b1.1
574 574
575 575 diff --git a/b1 b/b1
576 576 --- a/b1
577 577 +++ b/b1
578 578 @@ -1,1 +1,2 @@
579 579 b1
580 580 +postm
581 581
582 582
583 583
584 584 log -r ""
585 585
586 586 $ hg log -r ''
587 587 hg: parse error: empty query
588 588 [255]
589 589
590 590 log -r <some unknown node id>
591 591
592 592 $ hg log -r 1000000000000000000000000000000000000000
593 593 abort: unknown revision '1000000000000000000000000000000000000000'!
594 594 [255]
595 595
596 596 log -k r1
597 597
598 598 $ hg log -k r1
599 599 changeset: 1:3d5bf5654eda
600 600 user: test
601 601 date: Thu Jan 01 00:00:01 1970 +0000
602 602 summary: r1
603 603
604 604 log -p -l2 --color=always
605 605
606 606 $ hg --config extensions.color= --config color.mode=ansi \
607 607 > log -p -l2 --color=always
608 608 \x1b[0;33mchangeset: 6:2404bbcab562\x1b[0m (esc)
609 609 tag: tip
610 610 user: test
611 611 date: Thu Jan 01 00:00:01 1970 +0000
612 612 summary: b1.1
613 613
614 614 \x1b[0;1mdiff -r 302e9dd6890d -r 2404bbcab562 b1\x1b[0m (esc)
615 615 \x1b[0;31;1m--- a/b1 Thu Jan 01 00:00:01 1970 +0000\x1b[0m (esc)
616 616 \x1b[0;32;1m+++ b/b1 Thu Jan 01 00:00:01 1970 +0000\x1b[0m (esc)
617 617 \x1b[0;35m@@ -1,1 +1,2 @@\x1b[0m (esc)
618 618 b1
619 619 \x1b[0;32m+postm\x1b[0m (esc)
620 620
621 621 \x1b[0;33mchangeset: 5:302e9dd6890d\x1b[0m (esc)
622 622 parent: 3:e62f78d544b4
623 623 parent: 4:ddb82e70d1a1
624 624 user: test
625 625 date: Thu Jan 01 00:00:01 1970 +0000
626 626 summary: m12
627 627
628 628 \x1b[0;1mdiff -r e62f78d544b4 -r 302e9dd6890d b2\x1b[0m (esc)
629 629 \x1b[0;31;1m--- /dev/null Thu Jan 01 00:00:00 1970 +0000\x1b[0m (esc)
630 630 \x1b[0;32;1m+++ b/b2 Thu Jan 01 00:00:01 1970 +0000\x1b[0m (esc)
631 631 \x1b[0;35m@@ -0,0 +1,1 @@\x1b[0m (esc)
632 632 \x1b[0;32m+b2\x1b[0m (esc)
633 633
634 634
635 635
636 636 log -r tip --stat
637 637
638 638 $ hg log -r tip --stat
639 639 changeset: 6:2404bbcab562
640 640 tag: tip
641 641 user: test
642 642 date: Thu Jan 01 00:00:01 1970 +0000
643 643 summary: b1.1
644 644
645 645 b1 | 1 +
646 646 1 files changed, 1 insertions(+), 0 deletions(-)
647 647
648 648
649 649 $ cd ..
650 650
651 651
652 652 User
653 653
654 654 $ hg init usertest
655 655 $ cd usertest
656 656
657 657 $ echo a > a
658 658 $ hg ci -A -m "a" -u "User One <user1@example.org>"
659 659 adding a
660 660 $ echo b > b
661 661 $ hg ci -A -m "b" -u "User Two <user2@example.org>"
662 662 adding b
663 663
664 664 $ hg log -u "User One <user1@example.org>"
665 665 changeset: 0:29a4c94f1924
666 666 user: User One <user1@example.org>
667 667 date: Thu Jan 01 00:00:00 1970 +0000
668 668 summary: a
669 669
670 670 $ hg log -u "user1" -u "user2"
671 671 changeset: 1:e834b5e69c0e
672 672 tag: tip
673 673 user: User Two <user2@example.org>
674 674 date: Thu Jan 01 00:00:00 1970 +0000
675 675 summary: b
676 676
677 677 changeset: 0:29a4c94f1924
678 678 user: User One <user1@example.org>
679 679 date: Thu Jan 01 00:00:00 1970 +0000
680 680 summary: a
681 681
682 682 $ hg log -u "user3"
683 683
684 684 $ cd ..
685 685
686 686 $ hg init branches
687 687 $ cd branches
688 688
689 689 $ echo a > a
690 690 $ hg ci -A -m "commit on default"
691 691 adding a
692 692 $ hg branch test
693 693 marked working directory as branch test
694 694 (branches are permanent and global, did you want a bookmark?)
695 695 $ echo b > b
696 696 $ hg ci -A -m "commit on test"
697 697 adding b
698 698
699 699 $ hg up default
700 700 0 files updated, 0 files merged, 1 files removed, 0 files unresolved
701 701 $ echo c > c
702 702 $ hg ci -A -m "commit on default"
703 703 adding c
704 704 $ hg up test
705 705 1 files updated, 0 files merged, 1 files removed, 0 files unresolved
706 706 $ echo c > c
707 707 $ hg ci -A -m "commit on test"
708 708 adding c
709 709
710 710
711 711 log -b default
712 712
713 713 $ hg log -b default
714 714 changeset: 2:c3a4f03cc9a7
715 715 parent: 0:24427303d56f
716 716 user: test
717 717 date: Thu Jan 01 00:00:00 1970 +0000
718 718 summary: commit on default
719 719
720 720 changeset: 0:24427303d56f
721 721 user: test
722 722 date: Thu Jan 01 00:00:00 1970 +0000
723 723 summary: commit on default
724 724
725 725
726 726
727 727 log -b test
728 728
729 729 $ hg log -b test
730 730 changeset: 3:f5d8de11c2e2
731 731 branch: test
732 732 tag: tip
733 733 parent: 1:d32277701ccb
734 734 user: test
735 735 date: Thu Jan 01 00:00:00 1970 +0000
736 736 summary: commit on test
737 737
738 738 changeset: 1:d32277701ccb
739 739 branch: test
740 740 user: test
741 741 date: Thu Jan 01 00:00:00 1970 +0000
742 742 summary: commit on test
743 743
744 744
745 745
746 746 log -b dummy
747 747
748 748 $ hg log -b dummy
749 749 abort: unknown revision 'dummy'!
750 750 [255]
751 751
752 752
753 753 log -b .
754 754
755 755 $ hg log -b .
756 756 changeset: 3:f5d8de11c2e2
757 757 branch: test
758 758 tag: tip
759 759 parent: 1:d32277701ccb
760 760 user: test
761 761 date: Thu Jan 01 00:00:00 1970 +0000
762 762 summary: commit on test
763 763
764 764 changeset: 1:d32277701ccb
765 765 branch: test
766 766 user: test
767 767 date: Thu Jan 01 00:00:00 1970 +0000
768 768 summary: commit on test
769 769
770 770
771 771
772 772 log -b default -b test
773 773
774 774 $ hg log -b default -b test
775 775 changeset: 3:f5d8de11c2e2
776 776 branch: test
777 777 tag: tip
778 778 parent: 1:d32277701ccb
779 779 user: test
780 780 date: Thu Jan 01 00:00:00 1970 +0000
781 781 summary: commit on test
782 782
783 783 changeset: 2:c3a4f03cc9a7
784 784 parent: 0:24427303d56f
785 785 user: test
786 786 date: Thu Jan 01 00:00:00 1970 +0000
787 787 summary: commit on default
788 788
789 789 changeset: 1:d32277701ccb
790 790 branch: test
791 791 user: test
792 792 date: Thu Jan 01 00:00:00 1970 +0000
793 793 summary: commit on test
794 794
795 795 changeset: 0:24427303d56f
796 796 user: test
797 797 date: Thu Jan 01 00:00:00 1970 +0000
798 798 summary: commit on default
799 799
800 800
801 801
802 802 log -b default -b .
803 803
804 804 $ hg log -b default -b .
805 805 changeset: 3:f5d8de11c2e2
806 806 branch: test
807 807 tag: tip
808 808 parent: 1:d32277701ccb
809 809 user: test
810 810 date: Thu Jan 01 00:00:00 1970 +0000
811 811 summary: commit on test
812 812
813 813 changeset: 2:c3a4f03cc9a7
814 814 parent: 0:24427303d56f
815 815 user: test
816 816 date: Thu Jan 01 00:00:00 1970 +0000
817 817 summary: commit on default
818 818
819 819 changeset: 1:d32277701ccb
820 820 branch: test
821 821 user: test
822 822 date: Thu Jan 01 00:00:00 1970 +0000
823 823 summary: commit on test
824 824
825 825 changeset: 0:24427303d56f
826 826 user: test
827 827 date: Thu Jan 01 00:00:00 1970 +0000
828 828 summary: commit on default
829 829
830 830
831 831
832 832 log -b . -b test
833 833
834 834 $ hg log -b . -b test
835 835 changeset: 3:f5d8de11c2e2
836 836 branch: test
837 837 tag: tip
838 838 parent: 1:d32277701ccb
839 839 user: test
840 840 date: Thu Jan 01 00:00:00 1970 +0000
841 841 summary: commit on test
842 842
843 843 changeset: 1:d32277701ccb
844 844 branch: test
845 845 user: test
846 846 date: Thu Jan 01 00:00:00 1970 +0000
847 847 summary: commit on test
848 848
849 849
850 850
851 851 log -b 2
852 852
853 853 $ hg log -b 2
854 854 changeset: 2:c3a4f03cc9a7
855 855 parent: 0:24427303d56f
856 856 user: test
857 857 date: Thu Jan 01 00:00:00 1970 +0000
858 858 summary: commit on default
859 859
860 860 changeset: 0:24427303d56f
861 861 user: test
862 862 date: Thu Jan 01 00:00:00 1970 +0000
863 863 summary: commit on default
864 864
865 865
866 866
867 867 log -p --cwd dir (in subdir)
868 868
869 869 $ mkdir dir
870 870 $ hg log -p --cwd dir
871 871 changeset: 3:f5d8de11c2e2
872 872 branch: test
873 873 tag: tip
874 874 parent: 1:d32277701ccb
875 875 user: test
876 876 date: Thu Jan 01 00:00:00 1970 +0000
877 877 summary: commit on test
878 878
879 879 diff -r d32277701ccb -r f5d8de11c2e2 c
880 880 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
881 881 +++ b/c Thu Jan 01 00:00:00 1970 +0000
882 882 @@ -0,0 +1,1 @@
883 883 +c
884 884
885 885 changeset: 2:c3a4f03cc9a7
886 886 parent: 0:24427303d56f
887 887 user: test
888 888 date: Thu Jan 01 00:00:00 1970 +0000
889 889 summary: commit on default
890 890
891 891 diff -r 24427303d56f -r c3a4f03cc9a7 c
892 892 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
893 893 +++ b/c Thu Jan 01 00:00:00 1970 +0000
894 894 @@ -0,0 +1,1 @@
895 895 +c
896 896
897 897 changeset: 1:d32277701ccb
898 898 branch: test
899 899 user: test
900 900 date: Thu Jan 01 00:00:00 1970 +0000
901 901 summary: commit on test
902 902
903 903 diff -r 24427303d56f -r d32277701ccb b
904 904 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
905 905 +++ b/b Thu Jan 01 00:00:00 1970 +0000
906 906 @@ -0,0 +1,1 @@
907 907 +b
908 908
909 909 changeset: 0:24427303d56f
910 910 user: test
911 911 date: Thu Jan 01 00:00:00 1970 +0000
912 912 summary: commit on default
913 913
914 914 diff -r 000000000000 -r 24427303d56f a
915 915 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
916 916 +++ b/a Thu Jan 01 00:00:00 1970 +0000
917 917 @@ -0,0 +1,1 @@
918 918 +a
919 919
920 920
921 921
922 922 log -p -R repo
923 923
924 924 $ cd dir
925 925 $ hg log -p -R .. ../a
926 926 changeset: 0:24427303d56f
927 927 user: test
928 928 date: Thu Jan 01 00:00:00 1970 +0000
929 929 summary: commit on default
930 930
931 931 diff -r 000000000000 -r 24427303d56f a
932 932 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
933 933 +++ b/a Thu Jan 01 00:00:00 1970 +0000
934 934 @@ -0,0 +1,1 @@
935 935 +a
936 936
937 937
938 938 $ cd ../..
939 939
940 940 $ hg init follow2
941 941 $ cd follow2
942 942
943 943 # Build the following history:
944 944 # tip - o - x - o - x - x
945 945 # \ /
946 946 # o - o - o - x
947 947 # \ /
948 948 # o
949 949 #
950 950 # Where "o" is a revision containing "foo" and
951 951 # "x" is a revision without "foo"
952 952
953 953 $ touch init
954 954 $ hg ci -A -m "init, unrelated"
955 955 adding init
956 956 $ echo 'foo' > init
957 957 $ hg ci -m "change, unrelated"
958 958 $ echo 'foo' > foo
959 959 $ hg ci -A -m "add unrelated old foo"
960 960 adding foo
961 961 $ hg rm foo
962 962 $ hg ci -m "delete foo, unrelated"
963 963 $ echo 'related' > foo
964 964 $ hg ci -A -m "add foo, related"
965 965 adding foo
966 966
967 967 $ hg up 0
968 968 1 files updated, 0 files merged, 1 files removed, 0 files unresolved
969 969 $ touch branch
970 970 $ hg ci -A -m "first branch, unrelated"
971 971 adding branch
972 972 created new head
973 973 $ touch foo
974 974 $ hg ci -A -m "create foo, related"
975 975 adding foo
976 976 $ echo 'change' > foo
977 977 $ hg ci -m "change foo, related"
978 978
979 979 $ hg up 6
980 980 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
981 981 $ echo 'change foo in branch' > foo
982 982 $ hg ci -m "change foo in branch, related"
983 983 created new head
984 984 $ hg merge 7
985 985 merging foo
986 986 warning: conflicts during merge.
987 987 merging foo incomplete! (edit conflicts, then use 'hg resolve --mark')
988 988 0 files updated, 0 files merged, 0 files removed, 1 files unresolved
989 989 use 'hg resolve' to retry unresolved file merges or 'hg update -C .' to abandon
990 990 [1]
991 991 $ echo 'merge 1' > foo
992 992 $ hg resolve -m foo
993 no unresolved files; you may continue your unfinished operation
993 no more unresolved files
994 994 $ hg ci -m "First merge, related"
995 995
996 996 $ hg merge 4
997 997 merging foo
998 998 warning: conflicts during merge.
999 999 merging foo incomplete! (edit conflicts, then use 'hg resolve --mark')
1000 1000 1 files updated, 0 files merged, 0 files removed, 1 files unresolved
1001 1001 use 'hg resolve' to retry unresolved file merges or 'hg update -C .' to abandon
1002 1002 [1]
1003 1003 $ echo 'merge 2' > foo
1004 1004 $ hg resolve -m foo
1005 no unresolved files; you may continue your unfinished operation
1005 no more unresolved files
1006 1006 $ hg ci -m "Last merge, related"
1007 1007
1008 1008 $ hg log --graph
1009 1009 @ changeset: 10:4dae8563d2c5
1010 1010 |\ tag: tip
1011 1011 | | parent: 9:7b35701b003e
1012 1012 | | parent: 4:88176d361b69
1013 1013 | | user: test
1014 1014 | | date: Thu Jan 01 00:00:00 1970 +0000
1015 1015 | | summary: Last merge, related
1016 1016 | |
1017 1017 | o changeset: 9:7b35701b003e
1018 1018 | |\ parent: 8:e5416ad8a855
1019 1019 | | | parent: 7:87fe3144dcfa
1020 1020 | | | user: test
1021 1021 | | | date: Thu Jan 01 00:00:00 1970 +0000
1022 1022 | | | summary: First merge, related
1023 1023 | | |
1024 1024 | | o changeset: 8:e5416ad8a855
1025 1025 | | | parent: 6:dc6c325fe5ee
1026 1026 | | | user: test
1027 1027 | | | date: Thu Jan 01 00:00:00 1970 +0000
1028 1028 | | | summary: change foo in branch, related
1029 1029 | | |
1030 1030 | o | changeset: 7:87fe3144dcfa
1031 1031 | |/ user: test
1032 1032 | | date: Thu Jan 01 00:00:00 1970 +0000
1033 1033 | | summary: change foo, related
1034 1034 | |
1035 1035 | o changeset: 6:dc6c325fe5ee
1036 1036 | | user: test
1037 1037 | | date: Thu Jan 01 00:00:00 1970 +0000
1038 1038 | | summary: create foo, related
1039 1039 | |
1040 1040 | o changeset: 5:73db34516eb9
1041 1041 | | parent: 0:e87515fd044a
1042 1042 | | user: test
1043 1043 | | date: Thu Jan 01 00:00:00 1970 +0000
1044 1044 | | summary: first branch, unrelated
1045 1045 | |
1046 1046 o | changeset: 4:88176d361b69
1047 1047 | | user: test
1048 1048 | | date: Thu Jan 01 00:00:00 1970 +0000
1049 1049 | | summary: add foo, related
1050 1050 | |
1051 1051 o | changeset: 3:dd78ae4afb56
1052 1052 | | user: test
1053 1053 | | date: Thu Jan 01 00:00:00 1970 +0000
1054 1054 | | summary: delete foo, unrelated
1055 1055 | |
1056 1056 o | changeset: 2:c4c64aedf0f7
1057 1057 | | user: test
1058 1058 | | date: Thu Jan 01 00:00:00 1970 +0000
1059 1059 | | summary: add unrelated old foo
1060 1060 | |
1061 1061 o | changeset: 1:e5faa7440653
1062 1062 |/ user: test
1063 1063 | date: Thu Jan 01 00:00:00 1970 +0000
1064 1064 | summary: change, unrelated
1065 1065 |
1066 1066 o changeset: 0:e87515fd044a
1067 1067 user: test
1068 1068 date: Thu Jan 01 00:00:00 1970 +0000
1069 1069 summary: init, unrelated
1070 1070
1071 1071
1072 1072 $ hg --traceback log -f foo
1073 1073 changeset: 10:4dae8563d2c5
1074 1074 tag: tip
1075 1075 parent: 9:7b35701b003e
1076 1076 parent: 4:88176d361b69
1077 1077 user: test
1078 1078 date: Thu Jan 01 00:00:00 1970 +0000
1079 1079 summary: Last merge, related
1080 1080
1081 1081 changeset: 9:7b35701b003e
1082 1082 parent: 8:e5416ad8a855
1083 1083 parent: 7:87fe3144dcfa
1084 1084 user: test
1085 1085 date: Thu Jan 01 00:00:00 1970 +0000
1086 1086 summary: First merge, related
1087 1087
1088 1088 changeset: 8:e5416ad8a855
1089 1089 parent: 6:dc6c325fe5ee
1090 1090 user: test
1091 1091 date: Thu Jan 01 00:00:00 1970 +0000
1092 1092 summary: change foo in branch, related
1093 1093
1094 1094 changeset: 7:87fe3144dcfa
1095 1095 user: test
1096 1096 date: Thu Jan 01 00:00:00 1970 +0000
1097 1097 summary: change foo, related
1098 1098
1099 1099 changeset: 6:dc6c325fe5ee
1100 1100 user: test
1101 1101 date: Thu Jan 01 00:00:00 1970 +0000
1102 1102 summary: create foo, related
1103 1103
1104 1104 changeset: 4:88176d361b69
1105 1105 user: test
1106 1106 date: Thu Jan 01 00:00:00 1970 +0000
1107 1107 summary: add foo, related
1108 1108
1109 1109
1110 1110 Also check when maxrev < lastrevfilelog
1111 1111
1112 1112 $ hg --traceback log -f -r4 foo
1113 1113 changeset: 4:88176d361b69
1114 1114 user: test
1115 1115 date: Thu Jan 01 00:00:00 1970 +0000
1116 1116 summary: add foo, related
1117 1117
1118 1118 $ cd ..
1119 1119
1120 1120 Issue2383: hg log showing _less_ differences than hg diff
1121 1121
1122 1122 $ hg init issue2383
1123 1123 $ cd issue2383
1124 1124
1125 1125 Create a test repo:
1126 1126
1127 1127 $ echo a > a
1128 1128 $ hg ci -Am0
1129 1129 adding a
1130 1130 $ echo b > b
1131 1131 $ hg ci -Am1
1132 1132 adding b
1133 1133 $ hg co 0
1134 1134 0 files updated, 0 files merged, 1 files removed, 0 files unresolved
1135 1135 $ echo b > a
1136 1136 $ hg ci -m2
1137 1137 created new head
1138 1138
1139 1139 Merge:
1140 1140
1141 1141 $ hg merge
1142 1142 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
1143 1143 (branch merge, don't forget to commit)
1144 1144
1145 1145 Make sure there's a file listed in the merge to trigger the bug:
1146 1146
1147 1147 $ echo c > a
1148 1148 $ hg ci -m3
1149 1149
1150 1150 Two files shown here in diff:
1151 1151
1152 1152 $ hg diff --rev 2:3
1153 1153 diff -r b09be438c43a -r 8e07aafe1edc a
1154 1154 --- a/a Thu Jan 01 00:00:00 1970 +0000
1155 1155 +++ b/a Thu Jan 01 00:00:00 1970 +0000
1156 1156 @@ -1,1 +1,1 @@
1157 1157 -b
1158 1158 +c
1159 1159 diff -r b09be438c43a -r 8e07aafe1edc b
1160 1160 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1161 1161 +++ b/b Thu Jan 01 00:00:00 1970 +0000
1162 1162 @@ -0,0 +1,1 @@
1163 1163 +b
1164 1164
1165 1165 Diff here should be the same:
1166 1166
1167 1167 $ hg log -vpr 3
1168 1168 changeset: 3:8e07aafe1edc
1169 1169 tag: tip
1170 1170 parent: 2:b09be438c43a
1171 1171 parent: 1:925d80f479bb
1172 1172 user: test
1173 1173 date: Thu Jan 01 00:00:00 1970 +0000
1174 1174 files: a
1175 1175 description:
1176 1176 3
1177 1177
1178 1178
1179 1179 diff -r b09be438c43a -r 8e07aafe1edc a
1180 1180 --- a/a Thu Jan 01 00:00:00 1970 +0000
1181 1181 +++ b/a Thu Jan 01 00:00:00 1970 +0000
1182 1182 @@ -1,1 +1,1 @@
1183 1183 -b
1184 1184 +c
1185 1185 diff -r b09be438c43a -r 8e07aafe1edc b
1186 1186 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1187 1187 +++ b/b Thu Jan 01 00:00:00 1970 +0000
1188 1188 @@ -0,0 +1,1 @@
1189 1189 +b
1190 1190
1191 1191 $ cd ..
1192 1192
1193 1193 'hg log -r rev fn' when last(filelog(fn)) != rev
1194 1194
1195 1195 $ hg init simplelog
1196 1196 $ cd simplelog
1197 1197 $ echo f > a
1198 1198 $ hg ci -Am'a' -d '0 0'
1199 1199 adding a
1200 1200 $ echo f >> a
1201 1201 $ hg ci -Am'a bis' -d '1 0'
1202 1202
1203 1203 $ hg log -r0 a
1204 1204 changeset: 0:9f758d63dcde
1205 1205 user: test
1206 1206 date: Thu Jan 01 00:00:00 1970 +0000
1207 1207 summary: a
1208 1208
1209 1209 enable obsolete to test hidden feature
1210 1210
1211 1211 $ cat > ${TESTTMP}/obs.py << EOF
1212 1212 > import mercurial.obsolete
1213 1213 > mercurial.obsolete._enabled = True
1214 1214 > EOF
1215 1215 $ echo '[extensions]' >> $HGRCPATH
1216 1216 $ echo "obs=${TESTTMP}/obs.py" >> $HGRCPATH
1217 1217
1218 1218 $ hg log --template='{rev}:{node}\n'
1219 1219 1:a765632148dc55d38c35c4f247c618701886cb2f
1220 1220 0:9f758d63dcde62d547ebfb08e1e7ee96535f2b05
1221 1221 $ hg debugobsolete a765632148dc55d38c35c4f247c618701886cb2f
1222 1222 $ hg up null -q
1223 1223 $ hg log --template='{rev}:{node}\n'
1224 1224 0:9f758d63dcde62d547ebfb08e1e7ee96535f2b05
1225 1225 $ hg log --template='{rev}:{node}\n' --hidden
1226 1226 1:a765632148dc55d38c35c4f247c618701886cb2f
1227 1227 0:9f758d63dcde62d547ebfb08e1e7ee96535f2b05
1228 1228 $ hg log -r a
1229 1229 abort: unknown revision 'a'!
1230 1230 [255]
1231 1231
1232 1232 test that parent prevent a changeset to be hidden
1233 1233
1234 1234 $ hg up 1 -q --hidden
1235 1235 $ hg log --template='{rev}:{node}\n'
1236 1236 1:a765632148dc55d38c35c4f247c618701886cb2f
1237 1237 0:9f758d63dcde62d547ebfb08e1e7ee96535f2b05
1238 1238
1239 1239 test that second parent prevent a changeset to be hidden too
1240 1240
1241 1241 $ hg debugsetparents 0 1 # nothing suitable to merge here
1242 1242 $ hg log --template='{rev}:{node}\n'
1243 1243 1:a765632148dc55d38c35c4f247c618701886cb2f
1244 1244 0:9f758d63dcde62d547ebfb08e1e7ee96535f2b05
1245 1245 $ hg debugsetparents 1
1246 1246 $ hg up -q null
1247 1247
1248 1248 bookmarks prevent a changeset being hidden
1249 1249
1250 1250 $ hg bookmark --hidden -r 1 X
1251 1251 $ hg log --template '{rev}:{node}\n'
1252 1252 1:a765632148dc55d38c35c4f247c618701886cb2f
1253 1253 0:9f758d63dcde62d547ebfb08e1e7ee96535f2b05
1254 1254 $ hg bookmark -d X
1255 1255
1256 1256 divergent bookmarks are not hidden
1257 1257
1258 1258 $ hg bookmark --hidden -r 1 X@foo
1259 1259 $ hg log --template '{rev}:{node}\n'
1260 1260 1:a765632148dc55d38c35c4f247c618701886cb2f
1261 1261 0:9f758d63dcde62d547ebfb08e1e7ee96535f2b05
1262 1262
1263 1263 clear extensions configuration
1264 1264 $ echo '[extensions]' >> $HGRCPATH
1265 1265 $ echo "obs=!" >> $HGRCPATH
1266 1266 $ cd ..
1267 1267
1268 1268 test -u/-k for problematic encoding
1269 1269 # unicode: cp932:
1270 1270 # u30A2 0x83 0x41(= 'A')
1271 1271 # u30C2 0x83 0x61(= 'a')
1272 1272
1273 1273 $ hg init problematicencoding
1274 1274 $ cd problematicencoding
1275 1275
1276 1276 $ python > setup.sh <<EOF
1277 1277 > print u'''
1278 1278 > echo a > text
1279 1279 > hg add text
1280 1280 > hg --encoding utf-8 commit -u '\u30A2' -m none
1281 1281 > echo b > text
1282 1282 > hg --encoding utf-8 commit -u '\u30C2' -m none
1283 1283 > echo c > text
1284 1284 > hg --encoding utf-8 commit -u none -m '\u30A2'
1285 1285 > echo d > text
1286 1286 > hg --encoding utf-8 commit -u none -m '\u30C2'
1287 1287 > '''.encode('utf-8')
1288 1288 > EOF
1289 1289 $ sh < setup.sh
1290 1290
1291 1291 test in problematic encoding
1292 1292 $ python > test.sh <<EOF
1293 1293 > print u'''
1294 1294 > hg --encoding cp932 log --template '{rev}\\n' -u '\u30A2'
1295 1295 > echo ====
1296 1296 > hg --encoding cp932 log --template '{rev}\\n' -u '\u30C2'
1297 1297 > echo ====
1298 1298 > hg --encoding cp932 log --template '{rev}\\n' -k '\u30A2'
1299 1299 > echo ====
1300 1300 > hg --encoding cp932 log --template '{rev}\\n' -k '\u30C2'
1301 1301 > '''.encode('cp932')
1302 1302 > EOF
1303 1303 $ sh < test.sh
1304 1304 0
1305 1305 ====
1306 1306 1
1307 1307 ====
1308 1308 2
1309 1309 0
1310 1310 ====
1311 1311 3
1312 1312 1
1313 1313
1314 1314 $ cd ..
1315 1315
1316 1316 test hg log on non-existent files and on directories
1317 1317 $ hg init issue1340
1318 1318 $ cd issue1340
1319 1319 $ mkdir d1; mkdir D2; mkdir D3.i; mkdir d4.hg; mkdir d5.d; mkdir .d6
1320 1320 $ echo 1 > d1/f1
1321 1321 $ echo 1 > D2/f1
1322 1322 $ echo 1 > D3.i/f1
1323 1323 $ echo 1 > d4.hg/f1
1324 1324 $ echo 1 > d5.d/f1
1325 1325 $ echo 1 > .d6/f1
1326 1326 $ hg -q add .
1327 1327 $ hg commit -m "a bunch of weird directories"
1328 1328 $ hg log -l1 d1/f1 | grep changeset
1329 1329 changeset: 0:65624cd9070a
1330 1330 $ hg log -l1 f1
1331 1331 $ hg log -l1 . | grep changeset
1332 1332 changeset: 0:65624cd9070a
1333 1333 $ hg log -l1 ./ | grep changeset
1334 1334 changeset: 0:65624cd9070a
1335 1335 $ hg log -l1 d1 | grep changeset
1336 1336 changeset: 0:65624cd9070a
1337 1337 $ hg log -l1 D2 | grep changeset
1338 1338 changeset: 0:65624cd9070a
1339 1339 $ hg log -l1 D2/f1 | grep changeset
1340 1340 changeset: 0:65624cd9070a
1341 1341 $ hg log -l1 D3.i | grep changeset
1342 1342 changeset: 0:65624cd9070a
1343 1343 $ hg log -l1 D3.i/f1 | grep changeset
1344 1344 changeset: 0:65624cd9070a
1345 1345 $ hg log -l1 d4.hg | grep changeset
1346 1346 changeset: 0:65624cd9070a
1347 1347 $ hg log -l1 d4.hg/f1 | grep changeset
1348 1348 changeset: 0:65624cd9070a
1349 1349 $ hg log -l1 d5.d | grep changeset
1350 1350 changeset: 0:65624cd9070a
1351 1351 $ hg log -l1 d5.d/f1 | grep changeset
1352 1352 changeset: 0:65624cd9070a
1353 1353 $ hg log -l1 .d6 | grep changeset
1354 1354 changeset: 0:65624cd9070a
1355 1355 $ hg log -l1 .d6/f1 | grep changeset
1356 1356 changeset: 0:65624cd9070a
1357 1357
1358 1358 issue3772: hg log -r :null showing revision 0 as well
1359 1359
1360 1360 $ hg log -r :null
1361 1361 changeset: 0:65624cd9070a
1362 1362 tag: tip
1363 1363 user: test
1364 1364 date: Thu Jan 01 00:00:00 1970 +0000
1365 1365 summary: a bunch of weird directories
1366 1366
1367 1367 changeset: -1:000000000000
1368 1368 user:
1369 1369 date: Thu Jan 01 00:00:00 1970 +0000
1370 1370
1371 1371 $ hg log -r null:null
1372 1372 changeset: -1:000000000000
1373 1373 user:
1374 1374 date: Thu Jan 01 00:00:00 1970 +0000
1375 1375
1376 1376
1377 1377 $ cd ..
@@ -1,379 +1,379 b''
1 1 $ "$TESTDIR/hghave" symlink execbit || exit 80
2 2
3 3 $ tellmeabout() {
4 4 > if [ -h $1 ]; then
5 5 > echo $1 is a symlink:
6 6 > $TESTDIR/readlink.py $1
7 7 > elif [ -x $1 ]; then
8 8 > echo $1 is an executable file with content:
9 9 > cat $1
10 10 > else
11 11 > echo $1 is a plain file with content:
12 12 > cat $1
13 13 > fi
14 14 > }
15 15
16 16 $ hg init test1
17 17 $ cd test1
18 18
19 19 $ echo a > a
20 20 $ hg ci -Aqmadd
21 21 $ chmod +x a
22 22 $ hg ci -mexecutable
23 23
24 24 $ hg up -q 0
25 25 $ rm a
26 26 $ ln -s symlink a
27 27 $ hg ci -msymlink
28 28 created new head
29 29
30 30 Symlink is local parent, executable is other:
31 31
32 32 $ hg merge --debug
33 33 searching for copies back to rev 1
34 34 resolving manifests
35 35 branchmerge: True, force: False, partial: False
36 36 ancestor: c334dc3be0da, local: 521a1e40188f+, remote: 3574f3e69b1c
37 37 a: versions differ -> m
38 38 preserving a for resolve of a
39 39 updating: a 1/1 files (100.00%)
40 40 picked tool 'internal:merge' for a (binary False symlink True)
41 41 merging a
42 42 my a@521a1e40188f+ other a@3574f3e69b1c ancestor a@c334dc3be0da
43 43 warning: internal:merge cannot merge symlinks for a
44 44 merging a incomplete! (edit conflicts, then use 'hg resolve --mark')
45 45 0 files updated, 0 files merged, 0 files removed, 1 files unresolved
46 46 use 'hg resolve' to retry unresolved file merges or 'hg update -C .' to abandon
47 47 [1]
48 48
49 49 $ tellmeabout a
50 50 a is a symlink:
51 51 a -> symlink
52 52 $ hg resolve a --tool internal:other
53 no unresolved files; you may continue your unfinished operation
53 no more unresolved files
54 54 $ tellmeabout a
55 55 a is an executable file with content:
56 56 a
57 57 $ hg st
58 58 M a
59 59 ? a.orig
60 60
61 61 Symlink is other parent, executable is local:
62 62
63 63 $ hg update -C 1
64 64 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
65 65
66 66 $ hg merge --debug
67 67 searching for copies back to rev 1
68 68 resolving manifests
69 69 branchmerge: True, force: False, partial: False
70 70 ancestor: c334dc3be0da, local: 3574f3e69b1c+, remote: 521a1e40188f
71 71 a: versions differ -> m
72 72 preserving a for resolve of a
73 73 updating: a 1/1 files (100.00%)
74 74 picked tool 'internal:merge' for a (binary False symlink True)
75 75 merging a
76 76 my a@3574f3e69b1c+ other a@521a1e40188f ancestor a@c334dc3be0da
77 77 warning: internal:merge cannot merge symlinks for a
78 78 merging a incomplete! (edit conflicts, then use 'hg resolve --mark')
79 79 0 files updated, 0 files merged, 0 files removed, 1 files unresolved
80 80 use 'hg resolve' to retry unresolved file merges or 'hg update -C .' to abandon
81 81 [1]
82 82
83 83 $ tellmeabout a
84 84 a is an executable file with content:
85 85 a
86 86
87 87 Update to link without local change should get us a symlink (issue3316):
88 88
89 89 $ hg up -C 0
90 90 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
91 91 $ hg up
92 92 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
93 93 $ hg st
94 94 ? a.orig
95 95
96 96 Update to link with local change should cause a merge prompt (issue3200):
97 97
98 98 $ hg up -Cq 0
99 99 $ echo data > a
100 100 $ HGMERGE= hg up -y --debug
101 101 searching for copies back to rev 2
102 102 resolving manifests
103 103 branchmerge: False, force: False, partial: False
104 104 ancestor: c334dc3be0da, local: c334dc3be0da+, remote: 521a1e40188f
105 105 a: versions differ -> m
106 106 preserving a for resolve of a
107 107 updating: a 1/1 files (100.00%)
108 108 (couldn't find merge tool hgmerge|tool hgmerge can't handle symlinks) (re)
109 109 picked tool 'internal:prompt' for a (binary False symlink True)
110 110 no tool found to merge a
111 111 keep (l)ocal or take (o)ther? l
112 112 0 files updated, 1 files merged, 0 files removed, 0 files unresolved
113 113 $ hg diff --git
114 114 diff --git a/a b/a
115 115 old mode 120000
116 116 new mode 100644
117 117 --- a/a
118 118 +++ b/a
119 119 @@ -1,1 +1,1 @@
120 120 -symlink
121 121 \ No newline at end of file
122 122 +data
123 123
124 124
125 125 Test only 'l' change - happens rarely, except when recovering from situations
126 126 where that was what happened.
127 127
128 128 $ hg init test2
129 129 $ cd test2
130 130 $ printf base > f
131 131 $ hg ci -Aqm0
132 132 $ echo file > f
133 133 $ echo content >> f
134 134 $ hg ci -qm1
135 135 $ hg up -qr0
136 136 $ rm f
137 137 $ ln -s base f
138 138 $ hg ci -qm2
139 139 $ hg merge
140 140 merging f
141 141 warning: internal:merge cannot merge symlinks for f
142 142 merging f incomplete! (edit conflicts, then use 'hg resolve --mark')
143 143 0 files updated, 0 files merged, 0 files removed, 1 files unresolved
144 144 use 'hg resolve' to retry unresolved file merges or 'hg update -C .' to abandon
145 145 [1]
146 146 $ tellmeabout f
147 147 f is a symlink:
148 148 f -> base
149 149
150 150 $ hg up -Cqr1
151 151 $ hg merge
152 152 merging f
153 153 warning: internal:merge cannot merge symlinks for f
154 154 merging f incomplete! (edit conflicts, then use 'hg resolve --mark')
155 155 0 files updated, 0 files merged, 0 files removed, 1 files unresolved
156 156 use 'hg resolve' to retry unresolved file merges or 'hg update -C .' to abandon
157 157 [1]
158 158 $ tellmeabout f
159 159 f is a plain file with content:
160 160 file
161 161 content
162 162
163 163 $ cd ..
164 164
165 165 Test removed 'x' flag merged with change to symlink
166 166
167 167 $ hg init test3
168 168 $ cd test3
169 169 $ echo f > f
170 170 $ chmod +x f
171 171 $ hg ci -Aqm0
172 172 $ chmod -x f
173 173 $ hg ci -qm1
174 174 $ hg up -qr0
175 175 $ rm f
176 176 $ ln -s dangling f
177 177 $ hg ci -qm2
178 178 $ hg merge
179 179 merging f
180 180 warning: internal:merge cannot merge symlinks for f
181 181 merging f incomplete! (edit conflicts, then use 'hg resolve --mark')
182 182 0 files updated, 0 files merged, 0 files removed, 1 files unresolved
183 183 use 'hg resolve' to retry unresolved file merges or 'hg update -C .' to abandon
184 184 [1]
185 185 $ tellmeabout f
186 186 f is a symlink:
187 187 f -> dangling
188 188
189 189 $ hg up -Cqr1
190 190 $ hg merge
191 191 merging f
192 192 warning: internal:merge cannot merge symlinks for f
193 193 merging f incomplete! (edit conflicts, then use 'hg resolve --mark')
194 194 0 files updated, 0 files merged, 0 files removed, 1 files unresolved
195 195 use 'hg resolve' to retry unresolved file merges or 'hg update -C .' to abandon
196 196 [1]
197 197 $ tellmeabout f
198 198 f is a plain file with content:
199 199 f
200 200
201 201 Test removed 'x' flag merged with content change - both ways
202 202
203 203 $ hg up -Cqr0
204 204 $ echo change > f
205 205 $ hg ci -qm3
206 206 $ hg merge -r1
207 207 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
208 208 (branch merge, don't forget to commit)
209 209 $ tellmeabout f
210 210 f is a plain file with content:
211 211 change
212 212
213 213 $ hg up -qCr1
214 214 $ hg merge -r3
215 215 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
216 216 (branch merge, don't forget to commit)
217 217 $ tellmeabout f
218 218 f is a plain file with content:
219 219 change
220 220
221 221 $ cd ..
222 222
223 223 Test merge with no common ancestor:
224 224 a: just different
225 225 b: x vs -, different (cannot calculate x, cannot ask merge tool)
226 226 c: x vs -, same (cannot calculate x, merge tool is no good)
227 227 d: x vs l, different
228 228 e: x vs l, same
229 229 f: - vs l, different
230 230 g: - vs l, same
231 231 h: l vs l, different
232 232 (where same means the filelog entry is shared and there thus is an ancestor!)
233 233
234 234 $ hg init test4
235 235 $ cd test4
236 236 $ echo 0 > 0
237 237 $ hg ci -Aqm0
238 238
239 239 $ echo 1 > a
240 240 $ echo 1 > b
241 241 $ chmod +x b
242 242 $ echo x > c
243 243 $ chmod +x c
244 244 $ echo 1 > d
245 245 $ chmod +x d
246 246 $ printf x > e
247 247 $ chmod +x e
248 248 $ echo 1 > f
249 249 $ printf x > g
250 250 $ ln -s 1 h
251 251 $ hg ci -qAm1
252 252
253 253 $ hg up -qr0
254 254 $ echo 2 > a
255 255 $ echo 2 > b
256 256 $ echo x > c
257 257 $ ln -s 2 d
258 258 $ ln -s x e
259 259 $ ln -s 2 f
260 260 $ ln -s x g
261 261 $ ln -s 2 h
262 262 $ hg ci -Aqm2
263 263
264 264 $ hg merge
265 265 merging a
266 266 warning: conflicts during merge.
267 267 merging a incomplete! (edit conflicts, then use 'hg resolve --mark')
268 268 warning: cannot merge flags for b
269 269 merging b
270 270 warning: conflicts during merge.
271 271 merging b incomplete! (edit conflicts, then use 'hg resolve --mark')
272 272 warning: cannot merge flags for c
273 273 merging d
274 274 warning: internal:merge cannot merge symlinks for d
275 275 merging d incomplete! (edit conflicts, then use 'hg resolve --mark')
276 276 merging f
277 277 warning: internal:merge cannot merge symlinks for f
278 278 merging f incomplete! (edit conflicts, then use 'hg resolve --mark')
279 279 merging h
280 280 warning: internal:merge cannot merge symlinks for h
281 281 merging h incomplete! (edit conflicts, then use 'hg resolve --mark')
282 282 3 files updated, 0 files merged, 0 files removed, 5 files unresolved
283 283 use 'hg resolve' to retry unresolved file merges or 'hg update -C .' to abandon
284 284 [1]
285 285 $ hg resolve -l
286 286 U a
287 287 U b
288 288 U d
289 289 U f
290 290 U h
291 291 $ tellmeabout a
292 292 a is a plain file with content:
293 293 <<<<<<< local
294 294 2
295 295 =======
296 296 1
297 297 >>>>>>> other
298 298 $ tellmeabout b
299 299 b is a plain file with content:
300 300 <<<<<<< local
301 301 2
302 302 =======
303 303 1
304 304 >>>>>>> other
305 305 $ tellmeabout c
306 306 c is a plain file with content:
307 307 x
308 308 $ tellmeabout d
309 309 d is a symlink:
310 310 d -> 2
311 311 $ tellmeabout e
312 312 e is a symlink:
313 313 e -> x
314 314 $ tellmeabout f
315 315 f is a symlink:
316 316 f -> 2
317 317 $ tellmeabout g
318 318 g is a symlink:
319 319 g -> x
320 320 $ tellmeabout h
321 321 h is a symlink:
322 322 h -> 2
323 323
324 324 $ hg up -Cqr1
325 325 $ hg merge
326 326 merging a
327 327 warning: conflicts during merge.
328 328 merging a incomplete! (edit conflicts, then use 'hg resolve --mark')
329 329 warning: cannot merge flags for b
330 330 merging b
331 331 warning: conflicts during merge.
332 332 merging b incomplete! (edit conflicts, then use 'hg resolve --mark')
333 333 warning: cannot merge flags for c
334 334 merging d
335 335 warning: internal:merge cannot merge symlinks for d
336 336 merging d incomplete! (edit conflicts, then use 'hg resolve --mark')
337 337 merging f
338 338 warning: internal:merge cannot merge symlinks for f
339 339 merging f incomplete! (edit conflicts, then use 'hg resolve --mark')
340 340 merging h
341 341 warning: internal:merge cannot merge symlinks for h
342 342 merging h incomplete! (edit conflicts, then use 'hg resolve --mark')
343 343 3 files updated, 0 files merged, 0 files removed, 5 files unresolved
344 344 use 'hg resolve' to retry unresolved file merges or 'hg update -C .' to abandon
345 345 [1]
346 346 $ tellmeabout a
347 347 a is a plain file with content:
348 348 <<<<<<< local
349 349 1
350 350 =======
351 351 2
352 352 >>>>>>> other
353 353 $ tellmeabout b
354 354 b is an executable file with content:
355 355 <<<<<<< local
356 356 1
357 357 =======
358 358 2
359 359 >>>>>>> other
360 360 $ tellmeabout c
361 361 c is an executable file with content:
362 362 x
363 363 $ tellmeabout d
364 364 d is an executable file with content:
365 365 1
366 366 $ tellmeabout e
367 367 e is an executable file with content:
368 368 x (no-eol)
369 369 $ tellmeabout f
370 370 f is a plain file with content:
371 371 1
372 372 $ tellmeabout g
373 373 g is a plain file with content:
374 374 x (no-eol)
375 375 $ tellmeabout h
376 376 h is a symlink:
377 377 h -> 1
378 378
379 379 $ cd ..
@@ -1,148 +1,148 b''
1 1 initial
2 2 $ hg init test-a
3 3 $ cd test-a
4 4 $ cat >test.txt <<"EOF"
5 5 > 1
6 6 > 2
7 7 > 3
8 8 > EOF
9 9 $ hg add test.txt
10 10 $ hg commit -m "Initial"
11 11
12 12 clone
13 13 $ cd ..
14 14 $ hg clone test-a test-b
15 15 updating to branch default
16 16 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
17 17
18 18 change test-a
19 19 $ cd test-a
20 20 $ cat >test.txt <<"EOF"
21 21 > one
22 22 > two
23 23 > three
24 24 > EOF
25 25 $ hg commit -m "Numbers as words"
26 26
27 27 change test-b
28 28 $ cd ../test-b
29 29 $ cat >test.txt <<"EOF"
30 30 > 1
31 31 > 2.5
32 32 > 3
33 33 > EOF
34 34 $ hg commit -m "2 -> 2.5"
35 35
36 36 now pull and merge from test-a
37 37 $ hg pull ../test-a
38 38 pulling from ../test-a
39 39 searching for changes
40 40 adding changesets
41 41 adding manifests
42 42 adding file changes
43 43 added 1 changesets with 1 changes to 1 files (+1 heads)
44 44 (run 'hg heads' to see heads, 'hg merge' to merge)
45 45 $ hg merge
46 46 merging test.txt
47 47 warning: conflicts during merge.
48 48 merging test.txt incomplete! (edit conflicts, then use 'hg resolve --mark')
49 49 0 files updated, 0 files merged, 0 files removed, 1 files unresolved
50 50 use 'hg resolve' to retry unresolved file merges or 'hg update -C .' to abandon
51 51 [1]
52 52 resolve conflict
53 53 $ cat >test.txt <<"EOF"
54 54 > one
55 55 > two-point-five
56 56 > three
57 57 > EOF
58 58 $ rm -f *.orig
59 59 $ hg resolve -m test.txt
60 no unresolved files; you may continue your unfinished operation
60 no more unresolved files
61 61 $ hg commit -m "Merge 1"
62 62
63 63 change test-a again
64 64 $ cd ../test-a
65 65 $ cat >test.txt <<"EOF"
66 66 > one
67 67 > two-point-one
68 68 > three
69 69 > EOF
70 70 $ hg commit -m "two -> two-point-one"
71 71
72 72 pull and merge from test-a again
73 73 $ cd ../test-b
74 74 $ hg pull ../test-a
75 75 pulling from ../test-a
76 76 searching for changes
77 77 adding changesets
78 78 adding manifests
79 79 adding file changes
80 80 added 1 changesets with 1 changes to 1 files (+1 heads)
81 81 (run 'hg heads' to see heads, 'hg merge' to merge)
82 82 $ hg merge --debug
83 83 searching for copies back to rev 1
84 84 resolving manifests
85 85 branchmerge: True, force: False, partial: False
86 86 ancestor: 96b70246a118, local: 50c3a7e29886+, remote: 40d11a4173a8
87 87 test.txt: versions differ -> m
88 88 preserving test.txt for resolve of test.txt
89 89 updating: test.txt 1/1 files (100.00%)
90 90 picked tool 'internal:merge' for test.txt (binary False symlink False)
91 91 merging test.txt
92 92 my test.txt@50c3a7e29886+ other test.txt@40d11a4173a8 ancestor test.txt@96b70246a118
93 93 warning: conflicts during merge.
94 94 merging test.txt incomplete! (edit conflicts, then use 'hg resolve --mark')
95 95 0 files updated, 0 files merged, 0 files removed, 1 files unresolved
96 96 use 'hg resolve' to retry unresolved file merges or 'hg update -C .' to abandon
97 97 [1]
98 98
99 99 $ cat test.txt
100 100 one
101 101 <<<<<<< local
102 102 two-point-five
103 103 =======
104 104 two-point-one
105 105 >>>>>>> other
106 106 three
107 107
108 108 $ hg debugindex test.txt
109 109 rev offset length ..... linkrev nodeid p1 p2 (re)
110 110 0 0 7 ..... 0 01365c4cca56 000000000000 000000000000 (re)
111 111 1 7 9 ..... 1 7b013192566a 01365c4cca56 000000000000 (re)
112 112 2 16 15 ..... 2 8fe46a3eb557 01365c4cca56 000000000000 (re)
113 113 3 31 2. ..... 3 fc3148072371 7b013192566a 8fe46a3eb557 (re)
114 114 4 5. 25 ..... 4 d40249267ae3 8fe46a3eb557 000000000000 (re)
115 115
116 116 $ hg log
117 117 changeset: 4:40d11a4173a8
118 118 tag: tip
119 119 parent: 2:96b70246a118
120 120 user: test
121 121 date: Thu Jan 01 00:00:00 1970 +0000
122 122 summary: two -> two-point-one
123 123
124 124 changeset: 3:50c3a7e29886
125 125 parent: 1:d1e159716d41
126 126 parent: 2:96b70246a118
127 127 user: test
128 128 date: Thu Jan 01 00:00:00 1970 +0000
129 129 summary: Merge 1
130 130
131 131 changeset: 2:96b70246a118
132 132 parent: 0:b1832b9d912a
133 133 user: test
134 134 date: Thu Jan 01 00:00:00 1970 +0000
135 135 summary: Numbers as words
136 136
137 137 changeset: 1:d1e159716d41
138 138 user: test
139 139 date: Thu Jan 01 00:00:00 1970 +0000
140 140 summary: 2 -> 2.5
141 141
142 142 changeset: 0:b1832b9d912a
143 143 user: test
144 144 date: Thu Jan 01 00:00:00 1970 +0000
145 145 summary: Initial
146 146
147 147
148 148 $ cd ..
@@ -1,323 +1,323 b''
1 1
2 2 $ catpatch() {
3 3 > cat $1 | sed -e "s/^\(# Parent \).*/\1/"
4 4 > }
5 5 $ echo "[extensions]" >> $HGRCPATH
6 6 $ echo "mq=" >> $HGRCPATH
7 7 $ runtest() {
8 8 > hg init mq
9 9 > cd mq
10 10 >
11 11 > echo a > a
12 12 > hg ci -Ama
13 13 >
14 14 > echo '% qnew should refuse bad patch names'
15 15 > hg qnew series
16 16 > hg qnew status
17 17 > hg qnew guards
18 18 > hg qnew .
19 19 > hg qnew ..
20 20 > hg qnew .hgignore
21 21 > hg qnew .mqfoo
22 22 > hg qnew 'foo#bar'
23 23 > hg qnew 'foo:bar'
24 24 >
25 25 > hg qinit -c
26 26 >
27 27 > echo '% qnew with name containing slash'
28 28 > hg qnew foo/
29 29 > hg qnew foo/bar.patch
30 30 > hg qnew foo
31 31 > hg qseries
32 32 > hg qpop
33 33 > hg qdelete foo/bar.patch
34 34 >
35 35 > echo '% qnew with uncommitted changes'
36 36 > echo a > somefile
37 37 > hg add somefile
38 38 > hg qnew uncommitted.patch
39 39 > hg st
40 40 > hg qseries
41 41 >
42 42 > echo '% qnew implies add'
43 43 > hg -R .hg/patches st
44 44 >
45 45 > echo '% qnew missing'
46 46 > hg qnew missing.patch missing
47 47 >
48 48 > echo '% qnew -m'
49 49 > hg qnew -m 'foo bar' mtest.patch
50 50 > catpatch .hg/patches/mtest.patch
51 51 >
52 52 > echo '% qnew twice'
53 53 > hg qnew first.patch
54 54 > hg qnew first.patch
55 55 >
56 56 > touch ../first.patch
57 57 > hg qimport ../first.patch
58 58 >
59 59 > echo '% qnew -f from a subdirectory'
60 60 > hg qpop -a
61 61 > mkdir d
62 62 > cd d
63 63 > echo b > b
64 64 > hg ci -Am t
65 65 > echo b >> b
66 66 > hg st
67 67 > hg qnew -g -f p
68 68 > catpatch ../.hg/patches/p
69 69 >
70 70 > echo '% qnew -u with no username configured'
71 71 > HGUSER= hg qnew -u blue red
72 72 > catpatch ../.hg/patches/red
73 73 >
74 74 > echo '% qnew -e -u with no username configured'
75 75 > HGUSER= hg qnew -e -u chartreuse fucsia
76 76 > catpatch ../.hg/patches/fucsia
77 77 >
78 78 > echo '% fail when trying to import a merge'
79 79 > hg init merge
80 80 > cd merge
81 81 > touch a
82 82 > hg ci -Am null
83 83 > echo a >> a
84 84 > hg ci -m a
85 85 > hg up -r 0
86 86 > echo b >> a
87 87 > hg ci -m b
88 88 > hg merge -f 1
89 89 > hg resolve --mark a
90 90 > hg qnew -f merge
91 91 >
92 92 > cd ../../..
93 93 > rm -r mq
94 94 > }
95 95
96 96 plain headers
97 97
98 98 $ echo "[mq]" >> $HGRCPATH
99 99 $ echo "plain=true" >> $HGRCPATH
100 100 $ mkdir sandbox
101 101 $ (cd sandbox ; runtest)
102 102 adding a
103 103 % qnew should refuse bad patch names
104 104 abort: "series" cannot be used as the name of a patch
105 105 abort: "status" cannot be used as the name of a patch
106 106 abort: "guards" cannot be used as the name of a patch
107 107 abort: "." cannot be used as the name of a patch
108 108 abort: ".." cannot be used as the name of a patch
109 109 abort: patch name cannot begin with ".hg"
110 110 abort: patch name cannot begin with ".mq"
111 111 abort: "#" cannot be used in the name of a patch
112 112 abort: ":" cannot be used in the name of a patch
113 113 % qnew with name containing slash
114 114 abort: path ends in directory separator: foo/ (glob)
115 115 abort: "foo" already exists as a directory
116 116 foo/bar.patch
117 117 popping foo/bar.patch
118 118 patch queue now empty
119 119 % qnew with uncommitted changes
120 120 uncommitted.patch
121 121 % qnew implies add
122 122 A .hgignore
123 123 A series
124 124 A uncommitted.patch
125 125 % qnew missing
126 126 abort: missing: * (glob)
127 127 % qnew -m
128 128 foo bar
129 129
130 130 % qnew twice
131 131 abort: patch "first.patch" already exists
132 132 abort: patch "first.patch" already exists
133 133 % qnew -f from a subdirectory
134 134 popping first.patch
135 135 popping mtest.patch
136 136 popping uncommitted.patch
137 137 patch queue now empty
138 138 adding d/b
139 139 M d/b
140 140 diff --git a/d/b b/d/b
141 141 --- a/d/b
142 142 +++ b/d/b
143 143 @@ -1,1 +1,2 @@
144 144 b
145 145 +b
146 146 % qnew -u with no username configured
147 147 From: blue
148 148
149 149 % qnew -e -u with no username configured
150 150 From: chartreuse
151 151
152 152 % fail when trying to import a merge
153 153 adding a
154 154 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
155 155 created new head
156 156 merging a
157 157 warning: conflicts during merge.
158 158 merging a incomplete! (edit conflicts, then use 'hg resolve --mark')
159 159 0 files updated, 0 files merged, 0 files removed, 1 files unresolved
160 160 use 'hg resolve' to retry unresolved file merges or 'hg update -C .' to abandon
161 no unresolved files; you may continue your unfinished operation
161 no more unresolved files
162 162 abort: cannot manage merge changesets
163 163 $ rm -r sandbox
164 164
165 165 hg headers
166 166
167 167 $ echo "plain=false" >> $HGRCPATH
168 168 $ mkdir sandbox
169 169 $ (cd sandbox ; runtest)
170 170 adding a
171 171 % qnew should refuse bad patch names
172 172 abort: "series" cannot be used as the name of a patch
173 173 abort: "status" cannot be used as the name of a patch
174 174 abort: "guards" cannot be used as the name of a patch
175 175 abort: "." cannot be used as the name of a patch
176 176 abort: ".." cannot be used as the name of a patch
177 177 abort: patch name cannot begin with ".hg"
178 178 abort: patch name cannot begin with ".mq"
179 179 abort: "#" cannot be used in the name of a patch
180 180 abort: ":" cannot be used in the name of a patch
181 181 % qnew with name containing slash
182 182 abort: path ends in directory separator: foo/ (glob)
183 183 abort: "foo" already exists as a directory
184 184 foo/bar.patch
185 185 popping foo/bar.patch
186 186 patch queue now empty
187 187 % qnew with uncommitted changes
188 188 uncommitted.patch
189 189 % qnew implies add
190 190 A .hgignore
191 191 A series
192 192 A uncommitted.patch
193 193 % qnew missing
194 194 abort: missing: * (glob)
195 195 % qnew -m
196 196 # HG changeset patch
197 197 # Parent
198 198 foo bar
199 199
200 200 % qnew twice
201 201 abort: patch "first.patch" already exists
202 202 abort: patch "first.patch" already exists
203 203 % qnew -f from a subdirectory
204 204 popping first.patch
205 205 popping mtest.patch
206 206 popping uncommitted.patch
207 207 patch queue now empty
208 208 adding d/b
209 209 M d/b
210 210 # HG changeset patch
211 211 # Parent
212 212 diff --git a/d/b b/d/b
213 213 --- a/d/b
214 214 +++ b/d/b
215 215 @@ -1,1 +1,2 @@
216 216 b
217 217 +b
218 218 % qnew -u with no username configured
219 219 # HG changeset patch
220 220 # Parent
221 221 # User blue
222 222 % qnew -e -u with no username configured
223 223 # HG changeset patch
224 224 # Parent
225 225 # User chartreuse
226 226 % fail when trying to import a merge
227 227 adding a
228 228 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
229 229 created new head
230 230 merging a
231 231 warning: conflicts during merge.
232 232 merging a incomplete! (edit conflicts, then use 'hg resolve --mark')
233 233 0 files updated, 0 files merged, 0 files removed, 1 files unresolved
234 234 use 'hg resolve' to retry unresolved file merges or 'hg update -C .' to abandon
235 no unresolved files; you may continue your unfinished operation
235 no more unresolved files
236 236 abort: cannot manage merge changesets
237 237 $ rm -r sandbox
238 238
239 239 Test saving last-message.txt
240 240
241 241 $ hg init repo
242 242 $ cd repo
243 243
244 244 $ cat > $TESTTMP/commitfailure.py <<EOF
245 245 > from mercurial import util
246 246 > def reposetup(ui, repo):
247 247 > class commitfailure(repo.__class__):
248 248 > def commit(self, *args, **kwargs):
249 249 > raise util.Abort('emulating unexpected abort')
250 250 > repo.__class__ = commitfailure
251 251 > EOF
252 252 $ cat >> .hg/hgrc <<EOF
253 253 > [extensions]
254 254 > # this failure occurs before editor invocation
255 255 > commitfailure = $TESTTMP/commitfailure.py
256 256 > EOF
257 257
258 258 $ cat > $TESTTMP/editor.sh << EOF
259 259 > echo "==== before editing"
260 260 > cat \$1
261 261 > echo "===="
262 262 > echo "test saving last-message.txt" >> \$1
263 263 > EOF
264 264
265 265 (test that editor is not invoked before transaction starting)
266 266
267 267 $ rm -f .hg/last-message.txt
268 268 $ HGEDITOR="sh $TESTTMP/editor.sh" hg qnew -e patch
269 269 abort: emulating unexpected abort
270 270 [255]
271 271 $ cat .hg/last-message.txt
272 272 cat: .hg/last-message.txt: No such file or directory
273 273 [1]
274 274
275 275 (test that editor is invoked and commit message is saved into
276 276 "last-message.txt")
277 277
278 278 $ cat >> .hg/hgrc <<EOF
279 279 > [extensions]
280 280 > commitfailure = !
281 281 > [hooks]
282 282 > # this failure occurs after editor invocation
283 283 > pretxncommit.unexpectedabort = false
284 284 > EOF
285 285
286 286 $ rm -f .hg/last-message.txt
287 287 $ HGEDITOR="sh $TESTTMP/editor.sh" hg qnew -e patch
288 288 ==== before editing
289 289
290 290 ====
291 291 transaction abort!
292 292 rollback completed
293 293 note: commit message saved in .hg/last-message.txt
294 294 abort: pretxncommit.unexpectedabort hook exited with status 1
295 295 [255]
296 296 $ cat .hg/last-message.txt
297 297
298 298 test saving last-message.txt
299 299
300 300 $ cat >> .hg/hgrc <<EOF
301 301 > [hooks]
302 302 > pretxncommit.unexpectedabort =
303 303 > EOF
304 304
305 305 Test handling default message with the patch filename with tail whitespaces
306 306
307 307 $ cat > $TESTTMP/editor.sh << EOF
308 308 > echo "==== before editing"
309 309 > cat \$1
310 310 > echo "===="
311 311 > echo "[mq]: patch " > \$1
312 312 > EOF
313 313
314 314 $ rm -f .hg/last-message.txt
315 315 $ HGEDITOR="sh $TESTTMP/editor.sh" hg qnew -e "patch "
316 316 ==== before editing
317 317
318 318 ====
319 319 $ cat ".hg/patches/patch "
320 320 # HG changeset patch
321 321 # Parent 0000000000000000000000000000000000000000
322 322
323 323 $ cd ..
@@ -1,200 +1,200 b''
1 1 $ cat >> $HGRCPATH <<EOF
2 2 > [extensions]
3 3 > rebase=
4 4 >
5 5 > [phases]
6 6 > publish=False
7 7 >
8 8 > [alias]
9 9 > tglog = log -G --template "{rev}: '{desc}' bookmarks: {bookmarks}\n"
10 10 > EOF
11 11
12 12 Create a repo with several bookmarks
13 13 $ hg init a
14 14 $ cd a
15 15
16 16 $ echo a > a
17 17 $ hg ci -Am A
18 18 adding a
19 19
20 20 $ echo b > b
21 21 $ hg ci -Am B
22 22 adding b
23 23 $ hg book 'X'
24 24 $ hg book 'Y'
25 25
26 26 $ echo c > c
27 27 $ hg ci -Am C
28 28 adding c
29 29 $ hg book 'Z'
30 30
31 31 $ hg up -q 0
32 32
33 33 $ echo d > d
34 34 $ hg ci -Am D
35 35 adding d
36 36 created new head
37 37
38 38 $ hg book W
39 39
40 40 $ hg tglog
41 41 @ 3: 'D' bookmarks: W
42 42 |
43 43 | o 2: 'C' bookmarks: Y Z
44 44 | |
45 45 | o 1: 'B' bookmarks: X
46 46 |/
47 47 o 0: 'A' bookmarks:
48 48
49 49
50 50 Move only rebased bookmarks
51 51
52 52 $ cd ..
53 53 $ hg clone -q a a1
54 54
55 55 $ cd a1
56 56 $ hg up -q Z
57 57
58 58 Test deleting divergent bookmarks from dest (issue3685)
59 59
60 60 $ hg book -r 3 Z@diverge
61 61
62 62 ... and also test that bookmarks not on dest or not being moved aren't deleted
63 63
64 64 $ hg book -r 3 X@diverge
65 65 $ hg book -r 0 Y@diverge
66 66
67 67 $ hg tglog
68 68 o 3: 'D' bookmarks: W X@diverge Z@diverge
69 69 |
70 70 | @ 2: 'C' bookmarks: Y Z
71 71 | |
72 72 | o 1: 'B' bookmarks: X
73 73 |/
74 74 o 0: 'A' bookmarks: Y@diverge
75 75
76 76 $ hg rebase -s Y -d 3
77 77 saved backup bundle to $TESTTMP/a1/.hg/strip-backup/*-backup.hg (glob)
78 78
79 79 $ hg tglog
80 80 @ 3: 'C' bookmarks: Y Z
81 81 |
82 82 o 2: 'D' bookmarks: W X@diverge
83 83 |
84 84 | o 1: 'B' bookmarks: X
85 85 |/
86 86 o 0: 'A' bookmarks: Y@diverge
87 87
88 88 Do not try to keep active but deleted divergent bookmark
89 89
90 90 $ cd ..
91 91 $ hg clone -q a a4
92 92
93 93 $ cd a4
94 94 $ hg up -q 2
95 95 $ hg book W@diverge
96 96
97 97 $ hg rebase -s W -d .
98 98 saved backup bundle to $TESTTMP/a4/.hg/strip-backup/*-backup.hg (glob)
99 99
100 100 $ hg bookmarks
101 101 W 3:0d3554f74897
102 102 X 1:6c81ed0049f8
103 103 Y 2:49cb3485fa0c
104 104 Z 2:49cb3485fa0c
105 105
106 106 Keep bookmarks to the correct rebased changeset
107 107
108 108 $ cd ..
109 109 $ hg clone -q a a2
110 110
111 111 $ cd a2
112 112 $ hg up -q Z
113 113
114 114 $ hg rebase -s 1 -d 3
115 115 saved backup bundle to $TESTTMP/a2/.hg/strip-backup/*-backup.hg (glob)
116 116
117 117 $ hg tglog
118 118 @ 3: 'C' bookmarks: Y Z
119 119 |
120 120 o 2: 'B' bookmarks: X
121 121 |
122 122 o 1: 'D' bookmarks: W
123 123 |
124 124 o 0: 'A' bookmarks:
125 125
126 126
127 127 Keep active bookmark on the correct changeset
128 128
129 129 $ cd ..
130 130 $ hg clone -q a a3
131 131
132 132 $ cd a3
133 133 $ hg up -q X
134 134
135 135 $ hg rebase -d W
136 136 saved backup bundle to $TESTTMP/a3/.hg/strip-backup/*-backup.hg (glob)
137 137
138 138 $ hg tglog
139 139 o 3: 'C' bookmarks: Y Z
140 140 |
141 141 @ 2: 'B' bookmarks: X
142 142 |
143 143 o 1: 'D' bookmarks: W
144 144 |
145 145 o 0: 'A' bookmarks:
146 146
147 147 $ hg bookmarks
148 148 W 1:41acb9dca9eb
149 149 * X 2:e926fccfa8ec
150 150 Y 3:3d5fa227f4b5
151 151 Z 3:3d5fa227f4b5
152 152
153 153 rebase --continue with bookmarks present (issue3802)
154 154
155 155 $ hg up 2
156 156 0 files updated, 0 files merged, 0 files removed, 0 files unresolved
157 157 $ echo 'C' > c
158 158 $ hg add c
159 159 $ hg ci -m 'other C'
160 160 created new head
161 161 $ hg up 3
162 162 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
163 163 $ hg rebase
164 164 merging c
165 165 warning: conflicts during merge.
166 166 merging c incomplete! (edit conflicts, then use 'hg resolve --mark')
167 167 unresolved conflicts (see hg resolve, then hg rebase --continue)
168 168 [1]
169 169 $ echo 'c' > c
170 170 $ hg resolve --mark c
171 no unresolved files; you may continue your unfinished operation
171 no more unresolved files
172 172 $ hg rebase --continue
173 173 saved backup bundle to $TESTTMP/a3/.hg/strip-backup/3d5fa227f4b5-backup.hg (glob)
174 174 $ hg tglog
175 175 @ 4: 'C' bookmarks: Y Z
176 176 |
177 177 o 3: 'other C' bookmarks:
178 178 |
179 179 o 2: 'B' bookmarks: X
180 180 |
181 181 o 1: 'D' bookmarks: W
182 182 |
183 183 o 0: 'A' bookmarks:
184 184
185 185
186 186 ensure that bookmarks given the names of revset functions can be used
187 187 as --rev arguments (issue3950)
188 188
189 189 $ hg update -q 3
190 190 $ echo bimble > bimble
191 191 $ hg add bimble
192 192 $ hg commit -q -m 'bisect'
193 193 $ echo e >> bimble
194 194 $ hg ci -m bisect2
195 195 $ echo e >> bimble
196 196 $ hg ci -m bisect3
197 197 $ hg book bisect
198 198 $ hg update -q Y
199 199 $ hg rebase -r '"bisect"^^::"bisect"^' -r bisect -d Z
200 200 saved backup bundle to $TESTTMP/a3/.hg/strip-backup/345c90f326a4-backup.hg (glob)
@@ -1,151 +1,151 b''
1 1 $ cat >> $HGRCPATH <<EOF
2 2 > [extensions]
3 3 > rebase=
4 4 >
5 5 > [phases]
6 6 > publish=False
7 7 >
8 8 > [alias]
9 9 > tglog = log -G --template "{rev}:{phase} '{desc}' {branches}\n"
10 10 > EOF
11 11
12 12
13 13 $ hg init a
14 14 $ cd a
15 15
16 16 $ echo A > A
17 17 $ hg add A
18 18 $ hg ci -m A
19 19
20 20 $ echo 'B' > B
21 21 $ hg add B
22 22 $ hg ci -m B
23 23
24 24 $ echo C >> A
25 25 $ hg ci -m C
26 26
27 27 $ hg up -q -C 0
28 28
29 29 $ echo D >> A
30 30 $ hg ci -m D
31 31 created new head
32 32
33 33 $ echo E > E
34 34 $ hg add E
35 35 $ hg ci -m E
36 36
37 37 $ hg up -q -C 0
38 38
39 39 $ hg branch 'notdefault'
40 40 marked working directory as branch notdefault
41 41 (branches are permanent and global, did you want a bookmark?)
42 42 $ echo F >> A
43 43 $ hg ci -m F
44 44
45 45 $ cd ..
46 46
47 47
48 48 Rebasing B onto E - check keep: and phases
49 49
50 50 $ hg clone -q -u . a a1
51 51 $ cd a1
52 52 $ hg phase --force --secret 2
53 53
54 54 $ hg tglog
55 55 @ 5:draft 'F' notdefault
56 56 |
57 57 | o 4:draft 'E'
58 58 | |
59 59 | o 3:draft 'D'
60 60 |/
61 61 | o 2:secret 'C'
62 62 | |
63 63 | o 1:draft 'B'
64 64 |/
65 65 o 0:draft 'A'
66 66
67 67 $ hg rebase -s 1 -d 4 --keep
68 68 merging A
69 69 warning: conflicts during merge.
70 70 merging A incomplete! (edit conflicts, then use 'hg resolve --mark')
71 71 unresolved conflicts (see hg resolve, then hg rebase --continue)
72 72 [1]
73 73
74 74 Solve the conflict and go on:
75 75
76 76 $ echo 'conflict solved' > A
77 77 $ rm A.orig
78 78 $ hg resolve -m A
79 no unresolved files; you may continue your unfinished operation
79 no more unresolved files
80 80 $ hg rebase --continue
81 81
82 82 $ hg tglog
83 83 o 7:secret 'C'
84 84 |
85 85 o 6:draft 'B'
86 86 |
87 87 | @ 5:draft 'F' notdefault
88 88 | |
89 89 o | 4:draft 'E'
90 90 | |
91 91 o | 3:draft 'D'
92 92 |/
93 93 | o 2:secret 'C'
94 94 | |
95 95 | o 1:draft 'B'
96 96 |/
97 97 o 0:draft 'A'
98 98
99 99 $ cd ..
100 100
101 101
102 102 Rebase F onto E - check keepbranches:
103 103
104 104 $ hg clone -q -u . a a2
105 105 $ cd a2
106 106 $ hg phase --force --secret 2
107 107
108 108 $ hg tglog
109 109 @ 5:draft 'F' notdefault
110 110 |
111 111 | o 4:draft 'E'
112 112 | |
113 113 | o 3:draft 'D'
114 114 |/
115 115 | o 2:secret 'C'
116 116 | |
117 117 | o 1:draft 'B'
118 118 |/
119 119 o 0:draft 'A'
120 120
121 121 $ hg rebase -s 5 -d 4 --keepbranches
122 122 merging A
123 123 warning: conflicts during merge.
124 124 merging A incomplete! (edit conflicts, then use 'hg resolve --mark')
125 125 unresolved conflicts (see hg resolve, then hg rebase --continue)
126 126 [1]
127 127
128 128 Solve the conflict and go on:
129 129
130 130 $ echo 'conflict solved' > A
131 131 $ rm A.orig
132 132 $ hg resolve -m A
133 no unresolved files; you may continue your unfinished operation
133 no more unresolved files
134 134 $ hg rebase --continue
135 135 saved backup bundle to $TESTTMP/a2/.hg/strip-backup/*-backup.hg (glob)
136 136
137 137 $ hg tglog
138 138 @ 5:draft 'F' notdefault
139 139 |
140 140 o 4:draft 'E'
141 141 |
142 142 o 3:draft 'D'
143 143 |
144 144 | o 2:secret 'C'
145 145 | |
146 146 | o 1:draft 'B'
147 147 |/
148 148 o 0:draft 'A'
149 149
150 150
151 151 $ cd ..
@@ -1,307 +1,307 b''
1 1 $ cat >> $HGRCPATH <<EOF
2 2 > [extensions]
3 3 > rebase=
4 4 >
5 5 > [phases]
6 6 > publish=False
7 7 >
8 8 > [alias]
9 9 > tglog = log -G --template "{rev}:{phase} '{desc}' {branches} {bookmarks}\n"
10 10 > EOF
11 11
12 12 $ hg init a
13 13 $ cd a
14 14 $ echo c1 >common
15 15 $ hg add common
16 16 $ hg ci -m C1
17 17
18 18 $ echo c2 >>common
19 19 $ hg ci -m C2
20 20
21 21 $ echo c3 >>common
22 22 $ hg ci -m C3
23 23
24 24 $ hg up -q -C 1
25 25
26 26 $ echo l1 >>extra
27 27 $ hg add extra
28 28 $ hg ci -m L1
29 29 created new head
30 30
31 31 $ sed -e 's/c2/l2/' common > common.new
32 32 $ mv common.new common
33 33 $ hg ci -m L2
34 34
35 35 $ echo l3 >> extra2
36 36 $ hg add extra2
37 37 $ hg ci -m L3
38 38 $ hg bookmark mybook
39 39
40 40 $ hg phase --force --secret 4
41 41
42 42 $ hg tglog
43 43 @ 5:secret 'L3' mybook
44 44 |
45 45 o 4:secret 'L2'
46 46 |
47 47 o 3:draft 'L1'
48 48 |
49 49 | o 2:draft 'C3'
50 50 |/
51 51 o 1:draft 'C2'
52 52 |
53 53 o 0:draft 'C1'
54 54
55 55 Try to call --continue:
56 56
57 57 $ hg rebase --continue
58 58 abort: no rebase in progress
59 59 [255]
60 60
61 61 Conflicting rebase:
62 62
63 63 $ hg rebase -s 3 -d 2
64 64 merging common
65 65 warning: conflicts during merge.
66 66 merging common incomplete! (edit conflicts, then use 'hg resolve --mark')
67 67 unresolved conflicts (see hg resolve, then hg rebase --continue)
68 68 [1]
69 69
70 70 Try to continue without solving the conflict:
71 71
72 72 $ hg rebase --continue
73 73 abort: unresolved merge conflicts (see hg help resolve)
74 74 [255]
75 75
76 76 Conclude rebase:
77 77
78 78 $ echo 'resolved merge' >common
79 79 $ hg resolve -m common
80 no unresolved files; you may continue your unfinished operation
80 no more unresolved files
81 81 $ hg rebase --continue
82 82 saved backup bundle to $TESTTMP/a/.hg/strip-backup/*-backup.hg (glob)
83 83
84 84 $ hg tglog
85 85 @ 5:secret 'L3' mybook
86 86 |
87 87 o 4:secret 'L2'
88 88 |
89 89 o 3:draft 'L1'
90 90 |
91 91 o 2:draft 'C3'
92 92 |
93 93 o 1:draft 'C2'
94 94 |
95 95 o 0:draft 'C1'
96 96
97 97 Check correctness:
98 98
99 99 $ hg cat -r 0 common
100 100 c1
101 101
102 102 $ hg cat -r 1 common
103 103 c1
104 104 c2
105 105
106 106 $ hg cat -r 2 common
107 107 c1
108 108 c2
109 109 c3
110 110
111 111 $ hg cat -r 3 common
112 112 c1
113 113 c2
114 114 c3
115 115
116 116 $ hg cat -r 4 common
117 117 resolved merge
118 118
119 119 $ hg cat -r 5 common
120 120 resolved merge
121 121
122 122 Bookmark stays active after --continue
123 123 $ hg bookmarks
124 124 * mybook 5:d67b21408fc0
125 125
126 126 $ cd ..
127 127
128 128 Check that the right ancestors is used while rebasing a merge (issue4041)
129 129
130 130 $ hg clone "$TESTDIR/bundles/issue4041.hg" issue4041
131 131 requesting all changes
132 132 adding changesets
133 133 adding manifests
134 134 adding file changes
135 135 added 11 changesets with 8 changes to 3 files (+1 heads)
136 136 updating to branch default
137 137 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
138 138 $ cd issue4041
139 139 $ hg phase --draft --force 9
140 140 $ hg log -G
141 141 o changeset: 10:2f2496ddf49d
142 142 |\ branch: f1
143 143 | | tag: tip
144 144 | | parent: 7:4c9fbe56a16f
145 145 | | parent: 9:e31216eec445
146 146 | | user: szhang
147 147 | | date: Thu Sep 05 12:59:39 2013 -0400
148 148 | | summary: merge
149 149 | |
150 150 | o changeset: 9:e31216eec445
151 151 | | branch: f1
152 152 | | user: szhang
153 153 | | date: Thu Sep 05 12:59:10 2013 -0400
154 154 | | summary: more changes to f1
155 155 | |
156 156 | o changeset: 8:8e4e2c1a07ae
157 157 | |\ branch: f1
158 158 | | | parent: 2:4bc80088dc6b
159 159 | | | parent: 6:400110238667
160 160 | | | user: szhang
161 161 | | | date: Thu Sep 05 12:57:59 2013 -0400
162 162 | | | summary: bad merge
163 163 | | |
164 164 o | | changeset: 7:4c9fbe56a16f
165 165 |/ / branch: f1
166 166 | | parent: 2:4bc80088dc6b
167 167 | | user: szhang
168 168 | | date: Thu Sep 05 12:54:00 2013 -0400
169 169 | | summary: changed f1
170 170 | |
171 171 | o changeset: 6:400110238667
172 172 | | branch: f2
173 173 | | parent: 4:12e8ec6bb010
174 174 | | user: szhang
175 175 | | date: Tue Sep 03 13:58:02 2013 -0400
176 176 | | summary: changed f2 on f2
177 177 | |
178 178 | | @ changeset: 5:d79e2059b5c0
179 179 | | | parent: 3:8a951942e016
180 180 | | | user: szhang
181 181 | | | date: Tue Sep 03 13:57:39 2013 -0400
182 182 | | | summary: changed f2 on default
183 183 | | |
184 184 | o | changeset: 4:12e8ec6bb010
185 185 | |/ branch: f2
186 186 | | user: szhang
187 187 | | date: Tue Sep 03 13:57:18 2013 -0400
188 188 | | summary: created f2 branch
189 189 | |
190 190 | o changeset: 3:8a951942e016
191 191 | | parent: 0:24797d4f68de
192 192 | | user: szhang
193 193 | | date: Tue Sep 03 13:57:11 2013 -0400
194 194 | | summary: added f2.txt
195 195 | |
196 196 o | changeset: 2:4bc80088dc6b
197 197 | | branch: f1
198 198 | | user: szhang
199 199 | | date: Tue Sep 03 13:56:20 2013 -0400
200 200 | | summary: added f1.txt
201 201 | |
202 202 o | changeset: 1:ef53c9e6b608
203 203 |/ branch: f1
204 204 | user: szhang
205 205 | date: Tue Sep 03 13:55:26 2013 -0400
206 206 | summary: created f1 branch
207 207 |
208 208 o changeset: 0:24797d4f68de
209 209 user: szhang
210 210 date: Tue Sep 03 13:55:08 2013 -0400
211 211 summary: added default.txt
212 212
213 213 $ hg rebase -s9 -d2 --debug # use debug to really check merge base used
214 214 rebase onto 2 starting from e31216eec445
215 215 rebasing: 9:e31216eec445 5/6 changesets (83.33%)
216 216 future parents are 2 and -1
217 217 rebase status stored
218 218 update to 2:4bc80088dc6b
219 219 resolving manifests
220 220 branchmerge: False, force: True, partial: False
221 221 ancestor: d79e2059b5c0+, local: d79e2059b5c0+, remote: 4bc80088dc6b
222 222 f2.txt: other deleted -> r
223 223 f1.txt: remote created -> g
224 224 removing f2.txt
225 225 updating: f2.txt 1/2 files (50.00%)
226 226 getting f1.txt
227 227 updating: f1.txt 2/2 files (100.00%)
228 228 merge against 9:e31216eec445
229 229 detach base 8:8e4e2c1a07ae
230 230 searching for copies back to rev 3
231 231 resolving manifests
232 232 branchmerge: True, force: True, partial: False
233 233 ancestor: 8e4e2c1a07ae, local: 4bc80088dc6b+, remote: e31216eec445
234 234 f1.txt: remote is newer -> g
235 235 getting f1.txt
236 236 updating: f1.txt 1/1 files (100.00%)
237 237 f1.txt
238 238 rebasing: 10:2f2496ddf49d 6/6 changesets (100.00%)
239 239 future parents are 11 and 7
240 240 rebase status stored
241 241 already in target
242 242 merge against 10:2f2496ddf49d
243 243 detach base 9:e31216eec445
244 244 searching for copies back to rev 3
245 245 resolving manifests
246 246 branchmerge: True, force: True, partial: False
247 247 ancestor: e31216eec445, local: 19c888675e13+, remote: 2f2496ddf49d
248 248 f1.txt: remote is newer -> g
249 249 getting f1.txt
250 250 updating: f1.txt 1/1 files (100.00%)
251 251 f1.txt
252 252 rebase merging completed
253 253 update back to initial working directory parent
254 254 resolving manifests
255 255 branchmerge: False, force: False, partial: False
256 256 ancestor: 2a7f09cac94c, local: 2a7f09cac94c+, remote: d79e2059b5c0
257 257 f1.txt: other deleted -> r
258 258 f2.txt: remote created -> g
259 259 removing f1.txt
260 260 updating: f1.txt 1/2 files (50.00%)
261 261 getting f2.txt
262 262 updating: f2.txt 2/2 files (100.00%)
263 263 3 changesets found
264 264 list of changesets:
265 265 4c9fbe56a16f30c0d5dcc40ec1a97bbe3325209c
266 266 e31216eec445e44352c5f01588856059466a24c9
267 267 2f2496ddf49d69b5ef23ad8cf9fb2e0e4faf0ac2
268 268 bundling: 1/3 changesets (33.33%)
269 269 bundling: 2/3 changesets (66.67%)
270 270 bundling: 3/3 changesets (100.00%)
271 271 bundling: 1/3 manifests (33.33%)
272 272 bundling: 2/3 manifests (66.67%)
273 273 bundling: 3/3 manifests (100.00%)
274 274 bundling: f1.txt 1/1 files (100.00%)
275 275 saved backup bundle to $TESTTMP/issue4041/.hg/strip-backup/e31216eec445-backup.hg (glob)
276 276 3 changesets found
277 277 list of changesets:
278 278 4c9fbe56a16f30c0d5dcc40ec1a97bbe3325209c
279 279 19c888675e133ab5dff84516926a65672eaf04d9
280 280 2a7f09cac94c7f4b73ebd5cd1a62d3b2e8e336bf
281 281 bundling: 1/3 changesets (33.33%)
282 282 bundling: 2/3 changesets (66.67%)
283 283 bundling: 3/3 changesets (100.00%)
284 284 bundling: 1/3 manifests (33.33%)
285 285 bundling: 2/3 manifests (66.67%)
286 286 bundling: 3/3 manifests (100.00%)
287 287 bundling: f1.txt 1/1 files (100.00%)
288 288 adding branch
289 289 adding changesets
290 290 changesets: 1 chunks
291 291 add changeset 4c9fbe56a16f
292 292 changesets: 2 chunks
293 293 add changeset 19c888675e13
294 294 changesets: 3 chunks
295 295 add changeset 2a7f09cac94c
296 296 adding manifests
297 297 manifests: 1/2 chunks (50.00%)
298 298 manifests: 2/2 chunks (100.00%)
299 299 manifests: 3/2 chunks (150.00%)
300 300 adding file changes
301 301 adding f1.txt revisions
302 302 files: 1/1 chunks (100.00%)
303 303 added 2 changesets with 2 changes to 1 files
304 304 removing unknown node e31216eec445 from 1-phase boundary
305 305 invalid branchheads cache (served): tip differs
306 306 rebase completed
307 307 updating the branch cache
@@ -1,398 +1,398 b''
1 1 $ cat >> $HGRCPATH <<EOF
2 2 > [extensions]
3 3 > rebase=
4 4 >
5 5 > [phases]
6 6 > publish=False
7 7 >
8 8 > [alias]
9 9 > tglog = log -G --template "{rev}: '{desc}' {branches}\n"
10 10 > EOF
11 11
12 12
13 13 $ hg init a
14 14 $ cd a
15 15 $ hg unbundle "$TESTDIR/bundles/rebase.hg"
16 16 adding changesets
17 17 adding manifests
18 18 adding file changes
19 19 added 8 changesets with 7 changes to 7 files (+2 heads)
20 20 (run 'hg heads' to see heads, 'hg merge' to merge)
21 21 $ hg up tip
22 22 3 files updated, 0 files merged, 0 files removed, 0 files unresolved
23 23
24 24 $ cd ..
25 25
26 26
27 27 Rebasing D onto H detaching from C:
28 28
29 29 $ hg clone -q -u . a a1
30 30 $ cd a1
31 31
32 32 $ hg tglog
33 33 @ 7: 'H'
34 34 |
35 35 | o 6: 'G'
36 36 |/|
37 37 o | 5: 'F'
38 38 | |
39 39 | o 4: 'E'
40 40 |/
41 41 | o 3: 'D'
42 42 | |
43 43 | o 2: 'C'
44 44 | |
45 45 | o 1: 'B'
46 46 |/
47 47 o 0: 'A'
48 48
49 49 $ hg phase --force --secret 3
50 50 $ hg rebase -s 3 -d 7
51 51 saved backup bundle to $TESTTMP/a1/.hg/strip-backup/*-backup.hg (glob)
52 52
53 53 $ hg log -G --template "{rev}:{phase} '{desc}' {branches}\n"
54 54 o 7:secret 'D'
55 55 |
56 56 @ 6:draft 'H'
57 57 |
58 58 | o 5:draft 'G'
59 59 |/|
60 60 o | 4:draft 'F'
61 61 | |
62 62 | o 3:draft 'E'
63 63 |/
64 64 | o 2:draft 'C'
65 65 | |
66 66 | o 1:draft 'B'
67 67 |/
68 68 o 0:draft 'A'
69 69
70 70 $ hg manifest --rev tip
71 71 A
72 72 D
73 73 F
74 74 H
75 75
76 76 $ cd ..
77 77
78 78
79 79 Rebasing C onto H detaching from B:
80 80
81 81 $ hg clone -q -u . a a2
82 82 $ cd a2
83 83
84 84 $ hg tglog
85 85 @ 7: 'H'
86 86 |
87 87 | o 6: 'G'
88 88 |/|
89 89 o | 5: 'F'
90 90 | |
91 91 | o 4: 'E'
92 92 |/
93 93 | o 3: 'D'
94 94 | |
95 95 | o 2: 'C'
96 96 | |
97 97 | o 1: 'B'
98 98 |/
99 99 o 0: 'A'
100 100
101 101 $ hg rebase -s 2 -d 7
102 102 saved backup bundle to $TESTTMP/a2/.hg/strip-backup/*-backup.hg (glob)
103 103
104 104 $ hg tglog
105 105 o 7: 'D'
106 106 |
107 107 o 6: 'C'
108 108 |
109 109 @ 5: 'H'
110 110 |
111 111 | o 4: 'G'
112 112 |/|
113 113 o | 3: 'F'
114 114 | |
115 115 | o 2: 'E'
116 116 |/
117 117 | o 1: 'B'
118 118 |/
119 119 o 0: 'A'
120 120
121 121 $ hg manifest --rev tip
122 122 A
123 123 C
124 124 D
125 125 F
126 126 H
127 127
128 128 $ cd ..
129 129
130 130
131 131 Rebasing B onto H using detach (same as not using it):
132 132
133 133 $ hg clone -q -u . a a3
134 134 $ cd a3
135 135
136 136 $ hg tglog
137 137 @ 7: 'H'
138 138 |
139 139 | o 6: 'G'
140 140 |/|
141 141 o | 5: 'F'
142 142 | |
143 143 | o 4: 'E'
144 144 |/
145 145 | o 3: 'D'
146 146 | |
147 147 | o 2: 'C'
148 148 | |
149 149 | o 1: 'B'
150 150 |/
151 151 o 0: 'A'
152 152
153 153 $ hg rebase -s 1 -d 7
154 154 saved backup bundle to $TESTTMP/a3/.hg/strip-backup/*-backup.hg (glob)
155 155
156 156 $ hg tglog
157 157 o 7: 'D'
158 158 |
159 159 o 6: 'C'
160 160 |
161 161 o 5: 'B'
162 162 |
163 163 @ 4: 'H'
164 164 |
165 165 | o 3: 'G'
166 166 |/|
167 167 o | 2: 'F'
168 168 | |
169 169 | o 1: 'E'
170 170 |/
171 171 o 0: 'A'
172 172
173 173 $ hg manifest --rev tip
174 174 A
175 175 B
176 176 C
177 177 D
178 178 F
179 179 H
180 180
181 181 $ cd ..
182 182
183 183
184 184 Rebasing C onto H detaching from B and collapsing:
185 185
186 186 $ hg clone -q -u . a a4
187 187 $ cd a4
188 188 $ hg phase --force --secret 3
189 189
190 190 $ hg tglog
191 191 @ 7: 'H'
192 192 |
193 193 | o 6: 'G'
194 194 |/|
195 195 o | 5: 'F'
196 196 | |
197 197 | o 4: 'E'
198 198 |/
199 199 | o 3: 'D'
200 200 | |
201 201 | o 2: 'C'
202 202 | |
203 203 | o 1: 'B'
204 204 |/
205 205 o 0: 'A'
206 206
207 207 $ hg rebase --collapse -s 2 -d 7
208 208 saved backup bundle to $TESTTMP/a4/.hg/strip-backup/*-backup.hg (glob)
209 209
210 210 $ hg log -G --template "{rev}:{phase} '{desc}' {branches}\n"
211 211 o 6:secret 'Collapsed revision
212 212 | * C
213 213 | * D'
214 214 @ 5:draft 'H'
215 215 |
216 216 | o 4:draft 'G'
217 217 |/|
218 218 o | 3:draft 'F'
219 219 | |
220 220 | o 2:draft 'E'
221 221 |/
222 222 | o 1:draft 'B'
223 223 |/
224 224 o 0:draft 'A'
225 225
226 226 $ hg manifest --rev tip
227 227 A
228 228 C
229 229 D
230 230 F
231 231 H
232 232
233 233 $ cd ..
234 234
235 235 Rebasing across null as ancestor
236 236 $ hg clone -q -U a a5
237 237
238 238 $ cd a5
239 239
240 240 $ echo x > x
241 241
242 242 $ hg add x
243 243
244 244 $ hg ci -m "extra branch"
245 245 created new head
246 246
247 247 $ hg tglog
248 248 @ 8: 'extra branch'
249 249
250 250 o 7: 'H'
251 251 |
252 252 | o 6: 'G'
253 253 |/|
254 254 o | 5: 'F'
255 255 | |
256 256 | o 4: 'E'
257 257 |/
258 258 | o 3: 'D'
259 259 | |
260 260 | o 2: 'C'
261 261 | |
262 262 | o 1: 'B'
263 263 |/
264 264 o 0: 'A'
265 265
266 266 $ hg rebase -s 1 -d tip
267 267 saved backup bundle to $TESTTMP/a5/.hg/strip-backup/*-backup.hg (glob)
268 268
269 269 $ hg tglog
270 270 o 8: 'D'
271 271 |
272 272 o 7: 'C'
273 273 |
274 274 o 6: 'B'
275 275 |
276 276 @ 5: 'extra branch'
277 277
278 278 o 4: 'H'
279 279 |
280 280 | o 3: 'G'
281 281 |/|
282 282 o | 2: 'F'
283 283 | |
284 284 | o 1: 'E'
285 285 |/
286 286 o 0: 'A'
287 287
288 288
289 289 $ hg rebase -d 5 -s 7
290 290 saved backup bundle to $TESTTMP/a5/.hg/strip-backup/13547172c9c0-backup.hg (glob)
291 291 $ hg tglog
292 292 o 8: 'D'
293 293 |
294 294 o 7: 'C'
295 295 |
296 296 | o 6: 'B'
297 297 |/
298 298 @ 5: 'extra branch'
299 299
300 300 o 4: 'H'
301 301 |
302 302 | o 3: 'G'
303 303 |/|
304 304 o | 2: 'F'
305 305 | |
306 306 | o 1: 'E'
307 307 |/
308 308 o 0: 'A'
309 309
310 310 $ cd ..
311 311
312 312 Verify that target is not selected as external rev (issue3085)
313 313
314 314 $ hg clone -q -U a a6
315 315 $ cd a6
316 316 $ hg up -q 6
317 317
318 318 $ echo "I" >> E
319 319 $ hg ci -m "I"
320 320 $ hg merge 7
321 321 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
322 322 (branch merge, don't forget to commit)
323 323 $ hg ci -m "Merge"
324 324 $ echo "J" >> F
325 325 $ hg ci -m "J"
326 326
327 327 $ hg rebase -s 8 -d 7 --collapse --config ui.merge=internal:other
328 328 saved backup bundle to $TESTTMP/a6/.hg/strip-backup/*-backup.hg (glob)
329 329
330 330 $ hg tglog
331 331 @ 8: 'Collapsed revision
332 332 | * I
333 333 | * Merge
334 334 | * J'
335 335 o 7: 'H'
336 336 |
337 337 | o 6: 'G'
338 338 |/|
339 339 o | 5: 'F'
340 340 | |
341 341 | o 4: 'E'
342 342 |/
343 343 | o 3: 'D'
344 344 | |
345 345 | o 2: 'C'
346 346 | |
347 347 | o 1: 'B'
348 348 |/
349 349 o 0: 'A'
350 350
351 351
352 352 $ hg log --rev tip
353 353 changeset: 8:9472f4b1d736
354 354 tag: tip
355 355 user: test
356 356 date: Thu Jan 01 00:00:00 1970 +0000
357 357 summary: Collapsed revision
358 358
359 359
360 360 $ cd ..
361 361
362 362 Ensure --continue restores a correct state (issue3046) and phase:
363 363 $ hg clone -q a a7
364 364 $ cd a7
365 365 $ hg up -q 3
366 366 $ echo 'H2' > H
367 367 $ hg ci -A -m 'H2'
368 368 adding H
369 369 $ hg phase --force --secret 8
370 370 $ hg rebase -s 8 -d 7 --config ui.merge=internal:fail
371 371 merging H
372 372 warning: conflicts during merge.
373 373 merging H incomplete! (edit conflicts, then use 'hg resolve --mark')
374 374 unresolved conflicts (see hg resolve, then hg rebase --continue)
375 375 [1]
376 376 $ hg resolve --all -t internal:local
377 no unresolved files; you may continue your unfinished operation
377 no more unresolved files
378 378 $ hg rebase -c
379 379 saved backup bundle to $TESTTMP/a7/.hg/strip-backup/6215fafa5447-backup.hg (glob)
380 380 $ hg log -G --template "{rev}:{phase} '{desc}' {branches}\n"
381 381 @ 7:draft 'H'
382 382 |
383 383 | o 6:draft 'G'
384 384 |/|
385 385 o | 5:draft 'F'
386 386 | |
387 387 | o 4:draft 'E'
388 388 |/
389 389 | o 3:draft 'D'
390 390 | |
391 391 | o 2:draft 'C'
392 392 | |
393 393 | o 1:draft 'B'
394 394 |/
395 395 o 0:draft 'A'
396 396
397 397
398 398 $ cd ..
@@ -1,267 +1,267 b''
1 1 $ cat >> $HGRCPATH <<EOF
2 2 > [extensions]
3 3 > rebase=
4 4 >
5 5 > [phases]
6 6 > publish=False
7 7 >
8 8 > [alias]
9 9 > tglog = log -G --template "{rev}: '{desc}' {branches}\n"
10 10 > tglogp = log -G --template "{rev}:{phase} '{desc}' {branches}\n"
11 11 > EOF
12 12
13 13
14 14 $ hg init a
15 15 $ cd a
16 16
17 17 $ echo A > A
18 18 $ hg ci -Am A
19 19 adding A
20 20
21 21 $ echo B > B
22 22 $ hg ci -Am B
23 23 adding B
24 24
25 25 $ echo C >> A
26 26 $ hg ci -m C
27 27
28 28 $ hg up -q -C 0
29 29
30 30 $ echo D >> A
31 31 $ hg ci -m D
32 32 created new head
33 33
34 34 $ echo E > E
35 35 $ hg ci -Am E
36 36 adding E
37 37
38 38 $ cd ..
39 39
40 40
41 41 Changes during an interruption - continue:
42 42
43 43 $ hg clone -q -u . a a1
44 44 $ cd a1
45 45
46 46 $ hg tglog
47 47 @ 4: 'E'
48 48 |
49 49 o 3: 'D'
50 50 |
51 51 | o 2: 'C'
52 52 | |
53 53 | o 1: 'B'
54 54 |/
55 55 o 0: 'A'
56 56
57 57 Rebasing B onto E:
58 58
59 59 $ hg rebase -s 1 -d 4
60 60 merging A
61 61 warning: conflicts during merge.
62 62 merging A incomplete! (edit conflicts, then use 'hg resolve --mark')
63 63 unresolved conflicts (see hg resolve, then hg rebase --continue)
64 64 [1]
65 65
66 66 Force a commit on C during the interruption:
67 67
68 68 $ hg up -q -C 2 --config 'extensions.rebase=!'
69 69
70 70 $ echo 'Extra' > Extra
71 71 $ hg add Extra
72 72 $ hg ci -m 'Extra' --config 'extensions.rebase=!'
73 73
74 74 Force this commit onto secret phase
75 75
76 76 $ hg phase --force --secret 6
77 77
78 78 $ hg tglogp
79 79 @ 6:secret 'Extra'
80 80 |
81 81 | o 5:draft 'B'
82 82 | |
83 83 | o 4:draft 'E'
84 84 | |
85 85 | o 3:draft 'D'
86 86 | |
87 87 o | 2:draft 'C'
88 88 | |
89 89 o | 1:draft 'B'
90 90 |/
91 91 o 0:draft 'A'
92 92
93 93 Resume the rebasing:
94 94
95 95 $ hg rebase --continue
96 96 merging A
97 97 warning: conflicts during merge.
98 98 merging A incomplete! (edit conflicts, then use 'hg resolve --mark')
99 99 unresolved conflicts (see hg resolve, then hg rebase --continue)
100 100 [1]
101 101
102 102 Solve the conflict and go on:
103 103
104 104 $ echo 'conflict solved' > A
105 105 $ rm A.orig
106 106 $ hg resolve -m A
107 no unresolved files; you may continue your unfinished operation
107 no more unresolved files
108 108
109 109 $ hg rebase --continue
110 110 warning: new changesets detected on source branch, not stripping
111 111
112 112 $ hg tglogp
113 113 o 7:draft 'C'
114 114 |
115 115 | o 6:secret 'Extra'
116 116 | |
117 117 o | 5:draft 'B'
118 118 | |
119 119 @ | 4:draft 'E'
120 120 | |
121 121 o | 3:draft 'D'
122 122 | |
123 123 | o 2:draft 'C'
124 124 | |
125 125 | o 1:draft 'B'
126 126 |/
127 127 o 0:draft 'A'
128 128
129 129 $ cd ..
130 130
131 131
132 132 Changes during an interruption - abort:
133 133
134 134 $ hg clone -q -u . a a2
135 135 $ cd a2
136 136
137 137 $ hg tglog
138 138 @ 4: 'E'
139 139 |
140 140 o 3: 'D'
141 141 |
142 142 | o 2: 'C'
143 143 | |
144 144 | o 1: 'B'
145 145 |/
146 146 o 0: 'A'
147 147
148 148 Rebasing B onto E:
149 149
150 150 $ hg rebase -s 1 -d 4
151 151 merging A
152 152 warning: conflicts during merge.
153 153 merging A incomplete! (edit conflicts, then use 'hg resolve --mark')
154 154 unresolved conflicts (see hg resolve, then hg rebase --continue)
155 155 [1]
156 156
157 157 Force a commit on B' during the interruption:
158 158
159 159 $ hg up -q -C 5 --config 'extensions.rebase=!'
160 160
161 161 $ echo 'Extra' > Extra
162 162 $ hg add Extra
163 163 $ hg ci -m 'Extra' --config 'extensions.rebase=!'
164 164
165 165 $ hg tglog
166 166 @ 6: 'Extra'
167 167 |
168 168 o 5: 'B'
169 169 |
170 170 o 4: 'E'
171 171 |
172 172 o 3: 'D'
173 173 |
174 174 | o 2: 'C'
175 175 | |
176 176 | o 1: 'B'
177 177 |/
178 178 o 0: 'A'
179 179
180 180 Abort the rebasing:
181 181
182 182 $ hg rebase --abort
183 183 warning: new changesets detected on target branch, can't strip
184 184 rebase aborted
185 185
186 186 $ hg tglog
187 187 @ 6: 'Extra'
188 188 |
189 189 o 5: 'B'
190 190 |
191 191 o 4: 'E'
192 192 |
193 193 o 3: 'D'
194 194 |
195 195 | o 2: 'C'
196 196 | |
197 197 | o 1: 'B'
198 198 |/
199 199 o 0: 'A'
200 200
201 201 $ cd ..
202 202
203 203 Changes during an interruption - abort (again):
204 204
205 205 $ hg clone -q -u . a a3
206 206 $ cd a3
207 207
208 208 $ hg tglogp
209 209 @ 4:draft 'E'
210 210 |
211 211 o 3:draft 'D'
212 212 |
213 213 | o 2:draft 'C'
214 214 | |
215 215 | o 1:draft 'B'
216 216 |/
217 217 o 0:draft 'A'
218 218
219 219 Rebasing B onto E:
220 220
221 221 $ hg rebase -s 1 -d 4
222 222 merging A
223 223 warning: conflicts during merge.
224 224 merging A incomplete! (edit conflicts, then use 'hg resolve --mark')
225 225 unresolved conflicts (see hg resolve, then hg rebase --continue)
226 226 [1]
227 227
228 228 Change phase on B and B'
229 229
230 230 $ hg up -q -C 5 --config 'extensions.rebase=!'
231 231 $ hg phase --public 1
232 232 $ hg phase --public 5
233 233 $ hg phase --secret -f 2
234 234
235 235 $ hg tglogp
236 236 @ 5:public 'B'
237 237 |
238 238 o 4:public 'E'
239 239 |
240 240 o 3:public 'D'
241 241 |
242 242 | o 2:secret 'C'
243 243 | |
244 244 | o 1:public 'B'
245 245 |/
246 246 o 0:public 'A'
247 247
248 248 Abort the rebasing:
249 249
250 250 $ hg rebase --abort
251 251 warning: can't clean up immutable changesets 45396c49d53b
252 252 rebase aborted
253 253
254 254 $ hg tglogp
255 255 @ 5:public 'B'
256 256 |
257 257 o 4:public 'E'
258 258 |
259 259 o 3:public 'D'
260 260 |
261 261 | o 2:secret 'C'
262 262 | |
263 263 | o 1:public 'B'
264 264 |/
265 265 o 0:public 'A'
266 266
267 267 $ cd ..
@@ -1,139 +1,139 b''
1 1 This emulates the effects of an hg pull --rebase in which the remote repo
2 2 already has one local mq patch
3 3
4 4 $ cat >> $HGRCPATH <<EOF
5 5 > [extensions]
6 6 > rebase=
7 7 > mq=
8 8 >
9 9 > [phases]
10 10 > publish=False
11 11 >
12 12 > [alias]
13 13 > tglog = log -G --template "{rev}: '{desc}' tags: {tags}\n"
14 14 > EOF
15 15
16 16
17 17 $ hg init a
18 18 $ cd a
19 19 $ hg qinit -c
20 20
21 21 $ echo c1 > c1
22 22 $ hg add c1
23 23 $ hg ci -m C1
24 24
25 25 $ echo r1 > r1
26 26 $ hg add r1
27 27 $ hg ci -m R1
28 28
29 29 $ hg up -q 0
30 30
31 31 $ hg qnew p0.patch
32 32 $ echo p0 > p0
33 33 $ hg add p0
34 34 $ hg qref -m P0
35 35
36 36 $ hg qnew p1.patch
37 37 $ echo p1 > p1
38 38 $ hg add p1
39 39 $ hg qref -m P1
40 40
41 41 $ hg export qtip > p1.patch
42 42
43 43 $ hg up -q -C 1
44 44
45 45 $ hg import p1.patch
46 46 applying p1.patch
47 47
48 48 $ rm p1.patch
49 49
50 50 $ hg up -q -C qtip
51 51
52 52 $ hg rebase
53 53 saved backup bundle to $TESTTMP/a/.hg/strip-backup/*-backup.hg (glob)
54 54
55 55 $ hg tglog
56 56 @ 3: 'P0' tags: p0.patch qbase qtip tip
57 57 |
58 58 o 2: 'P1' tags: qparent
59 59 |
60 60 o 1: 'R1' tags:
61 61 |
62 62 o 0: 'C1' tags:
63 63
64 64 $ cd ..
65 65
66 66
67 67 $ hg init b
68 68 $ cd b
69 69 $ hg qinit -c
70 70
71 71 $ for i in r0 r1 r2 r3 r4 r5 r6;
72 72 > do
73 73 > echo $i > $i
74 74 > hg ci -Am $i
75 75 > done
76 76 adding r0
77 77 adding r1
78 78 adding r2
79 79 adding r3
80 80 adding r4
81 81 adding r5
82 82 adding r6
83 83
84 84 $ hg qimport -r 1:tip
85 85
86 86 $ hg up -q 0
87 87
88 88 $ for i in r1 r3 r7 r8;
89 89 > do
90 90 > echo $i > $i
91 91 > hg ci -Am branch2-$i
92 92 > done
93 93 adding r1
94 94 created new head
95 95 adding r3
96 96 adding r7
97 97 adding r8
98 98
99 99 $ echo somethingelse > r4
100 100 $ hg ci -Am branch2-r4
101 101 adding r4
102 102
103 103 $ echo r6 > r6
104 104 $ hg ci -Am branch2-r6
105 105 adding r6
106 106
107 107 $ hg up -q qtip
108 108
109 109 $ HGMERGE=internal:fail hg rebase
110 110 unresolved conflicts (see hg resolve, then hg rebase --continue)
111 111 [1]
112 112
113 113 $ HGMERGE=internal:local hg resolve --all
114 no unresolved files; you may continue your unfinished operation
114 no more unresolved files
115 115
116 116 $ hg rebase --continue
117 117 saved backup bundle to $TESTTMP/b/.hg/strip-backup/*-backup.hg (glob)
118 118
119 119 $ hg tglog
120 120 @ 8: 'r5' tags: 5.diff qtip tip
121 121 |
122 122 o 7: 'r2' tags: 2.diff qbase
123 123 |
124 124 o 6: 'branch2-r6' tags: qparent
125 125 |
126 126 o 5: 'branch2-r4' tags:
127 127 |
128 128 o 4: 'branch2-r8' tags:
129 129 |
130 130 o 3: 'branch2-r7' tags:
131 131 |
132 132 o 2: 'branch2-r3' tags:
133 133 |
134 134 o 1: 'branch2-r1' tags:
135 135 |
136 136 o 0: 'r0' tags:
137 137
138 138
139 139 $ cd ..
@@ -1,348 +1,348 b''
1 1 $ cat >> $HGRCPATH <<EOF
2 2 > [extensions]
3 3 > rebase=
4 4 > mq=
5 5 >
6 6 > [mq]
7 7 > plain=true
8 8 >
9 9 > [alias]
10 10 > tglog = log -G --template "{rev}: '{desc}' tags: {tags}\n"
11 11 > EOF
12 12
13 13
14 14 $ hg init a
15 15 $ cd a
16 16 $ hg qinit -c
17 17
18 18 $ echo c1 > f
19 19 $ hg add f
20 20 $ hg ci -m C1
21 21
22 22 $ echo r1 > f
23 23 $ hg ci -m R1
24 24
25 25 $ hg up -q 0
26 26
27 27 $ hg qnew f.patch
28 28 $ echo mq1 > f
29 29 $ hg qref -m P0
30 30
31 31 $ hg qnew f2.patch
32 32 $ echo mq2 > f
33 33 $ hg qref -m P1
34 34
35 35 $ hg tglog
36 36 @ 3: 'P1' tags: f2.patch qtip tip
37 37 |
38 38 o 2: 'P0' tags: f.patch qbase
39 39 |
40 40 | o 1: 'R1' tags:
41 41 |/
42 42 o 0: 'C1' tags: qparent
43 43
44 44
45 45 Rebase - try to rebase on an applied mq patch:
46 46
47 47 $ hg rebase -s 1 -d 3
48 48 abort: cannot rebase onto an applied mq patch
49 49 [255]
50 50
51 51 Rebase - same thing, but mq patch is default dest:
52 52
53 53 $ hg up -q 1
54 54 $ hg rebase
55 55 abort: cannot rebase onto an applied mq patch
56 56 [255]
57 57 $ hg up -q qtip
58 58
59 59 Rebase - generate a conflict:
60 60
61 61 $ hg rebase -s 2 -d 1
62 62 merging f
63 63 warning: conflicts during merge.
64 64 merging f incomplete! (edit conflicts, then use 'hg resolve --mark')
65 65 unresolved conflicts (see hg resolve, then hg rebase --continue)
66 66 [1]
67 67
68 68 Fix the 1st conflict:
69 69
70 70 $ echo mq1r1 > f
71 71 $ hg resolve -m f
72 no unresolved files; you may continue your unfinished operation
72 no more unresolved files
73 73 $ hg rebase -c
74 74 merging f
75 75 warning: conflicts during merge.
76 76 merging f incomplete! (edit conflicts, then use 'hg resolve --mark')
77 77 unresolved conflicts (see hg resolve, then hg rebase --continue)
78 78 [1]
79 79
80 80 Fix the 2nd conflict:
81 81
82 82 $ echo mq1r1mq2 > f
83 83 $ hg resolve -m f
84 no unresolved files; you may continue your unfinished operation
84 no more unresolved files
85 85 $ hg rebase -c
86 86 saved backup bundle to $TESTTMP/a/.hg/strip-backup/*-backup.hg (glob)
87 87
88 88 $ hg tglog
89 89 @ 3: 'P1' tags: f2.patch qtip tip
90 90 |
91 91 o 2: 'P0' tags: f.patch qbase
92 92 |
93 93 o 1: 'R1' tags: qparent
94 94 |
95 95 o 0: 'C1' tags:
96 96
97 97 $ hg up -q qbase
98 98
99 99 $ cat f
100 100 mq1r1
101 101
102 102 $ cat .hg/patches/f.patch
103 103 # HG changeset patch
104 104 # User test
105 105 # Date ?????????? ? (glob)
106 106 # * (glob)
107 107 # Node ID ???????????????????????????????????????? (glob)
108 108 # Parent bac9ed9960d8992bcad75864a879fa76cadaf1b0
109 109 P0
110 110
111 111 diff -r bac9ed9960d8 -r ???????????? f (glob)
112 112 --- a/f Thu Jan 01 00:00:00 1970 +0000
113 113 +++ b/f ??? ??? ?? ??:??:?? ???? ????? (glob)
114 114 @@ -1,1 +1,1 @@
115 115 -r1
116 116 +mq1r1
117 117
118 118 Update to qtip:
119 119
120 120 $ hg up -q qtip
121 121
122 122 $ cat f
123 123 mq1r1mq2
124 124
125 125 $ cat .hg/patches/f2.patch
126 126 # HG changeset patch
127 127 # User test
128 128 # Date ?????????? ? (glob)
129 129 # * (glob)
130 130 # Node ID ???????????????????????????????????????? (glob)
131 131 # Parent ???????????????????????????????????????? (glob)
132 132 P1
133 133
134 134 diff -r ???????????? -r ???????????? f (glob)
135 135 --- a/f ??? ??? ?? ??:??:?? ???? ????? (glob)
136 136 +++ b/f ??? ??? ?? ??:??:?? ???? ????? (glob)
137 137 @@ -1,1 +1,1 @@
138 138 -mq1r1
139 139 +mq1r1mq2
140 140
141 141 Adding one git-style patch and one normal:
142 142
143 143 $ hg qpop -a
144 144 popping f2.patch
145 145 popping f.patch
146 146 patch queue now empty
147 147
148 148 $ rm -fr .hg/patches
149 149 $ hg qinit -c
150 150
151 151 $ hg up -q 0
152 152
153 153 $ hg qnew --git f_git.patch
154 154 $ echo mq1 > p
155 155 $ hg add p
156 156 $ hg qref --git -m 'P0 (git)'
157 157
158 158 $ hg qnew f.patch
159 159 $ echo mq2 > p
160 160 $ hg qref -m P1
161 161 $ hg qci -m 'save patch state'
162 162
163 163 $ hg qseries -s
164 164 f_git.patch: P0 (git)
165 165 f.patch: P1
166 166
167 167 $ hg -R .hg/patches manifest
168 168 .hgignore
169 169 f.patch
170 170 f_git.patch
171 171 series
172 172
173 173 $ cat .hg/patches/f_git.patch
174 174 P0 (git)
175 175
176 176 diff --git a/p b/p
177 177 new file mode 100644
178 178 --- /dev/null
179 179 +++ b/p
180 180 @@ -0,0 +1,1 @@
181 181 +mq1
182 182
183 183 $ cat .hg/patches/f.patch
184 184 P1
185 185
186 186 diff -r ???????????? p (glob)
187 187 --- a/p ??? ??? ?? ??:??:?? ???? ????? (glob)
188 188 +++ b/p ??? ??? ?? ??:??:?? ???? ????? (glob)
189 189 @@ -1,1 +1,1 @@
190 190 -mq1
191 191 +mq2
192 192
193 193
194 194 Rebase the applied mq patches:
195 195
196 196 $ hg rebase -s 2 -d 1
197 197 saved backup bundle to $TESTTMP/a/.hg/strip-backup/*-backup.hg (glob)
198 198
199 199 $ hg qci -m 'save patch state'
200 200
201 201 $ hg qseries -s
202 202 f_git.patch: P0 (git)
203 203 f.patch: P1
204 204
205 205 $ hg -R .hg/patches manifest
206 206 .hgignore
207 207 f.patch
208 208 f_git.patch
209 209 series
210 210
211 211 $ cat .hg/patches/f_git.patch
212 212 # HG changeset patch
213 213 # User test
214 214 # Date ?????????? ? (glob)
215 215 # * (glob)
216 216 # Node ID ???????????????????????????????????????? (glob)
217 217 # Parent bac9ed9960d8992bcad75864a879fa76cadaf1b0
218 218 P0 (git)
219 219
220 220 diff --git a/p b/p
221 221 new file mode 100644
222 222 --- /dev/null
223 223 +++ b/p
224 224 @@ -0,0 +1,1 @@
225 225 +mq1
226 226
227 227 $ cat .hg/patches/f.patch
228 228 # HG changeset patch
229 229 # User test
230 230 # Date ?????????? ? (glob)
231 231 # * (glob)
232 232 # Node ID ???????????????????????????????????????? (glob)
233 233 # Parent ???????????????????????????????????????? (glob)
234 234 P1
235 235
236 236 diff -r ???????????? -r ???????????? p (glob)
237 237 --- a/p ??? ??? ?? ??:??:?? ???? ????? (glob)
238 238 +++ b/p ??? ??? ?? ??:??:?? ???? ????? (glob)
239 239 @@ -1,1 +1,1 @@
240 240 -mq1
241 241 +mq2
242 242
243 243 $ cd ..
244 244
245 245 Rebase with guards
246 246
247 247 $ hg init foo
248 248 $ cd foo
249 249 $ echo a > a
250 250 $ hg ci -Am a
251 251 adding a
252 252
253 253 Create mq repo with guarded patches foo and bar and empty patch:
254 254
255 255 $ hg qinit
256 256 $ echo guarded > guarded
257 257 $ hg add guarded
258 258 $ hg qnew guarded
259 259 $ hg qnew empty-important -m 'important commit message'
260 260 $ echo bar > bar
261 261 $ hg add bar
262 262 $ hg qnew bar
263 263 $ echo foo > foo
264 264 $ hg add foo
265 265 $ hg qnew foo
266 266 $ hg qpop -a
267 267 popping foo
268 268 popping bar
269 269 popping empty-important
270 270 popping guarded
271 271 patch queue now empty
272 272 $ hg qguard guarded +guarded
273 273 $ hg qguard bar +baz
274 274 $ hg qguard foo +baz
275 275 $ hg qselect baz
276 276 number of unguarded, unapplied patches has changed from 1 to 3
277 277 $ hg qpush bar
278 278 applying empty-important
279 279 patch empty-important is empty
280 280 applying bar
281 281 now at: bar
282 282
283 283 $ hg qguard -l
284 284 guarded: +guarded
285 285 empty-important: unguarded
286 286 bar: +baz
287 287 foo: +baz
288 288
289 289 $ hg tglog
290 290 @ 2: 'imported patch bar' tags: bar qtip tip
291 291 |
292 292 o 1: 'important commit message' tags: empty-important qbase
293 293 |
294 294 o 0: 'a' tags: qparent
295 295
296 296 Create new head to rebase bar onto:
297 297
298 298 $ hg up -C 0
299 299 0 files updated, 0 files merged, 1 files removed, 0 files unresolved
300 300 $ echo b > b
301 301 $ hg add b
302 302 $ hg ci -m b
303 303 created new head
304 304 $ hg up -C 2
305 305 1 files updated, 0 files merged, 1 files removed, 0 files unresolved
306 306 $ echo a >> a
307 307 $ hg qref
308 308
309 309 $ hg tglog
310 310 @ 3: '[mq]: bar' tags: bar qtip tip
311 311 |
312 312 | o 2: 'b' tags:
313 313 | |
314 314 o | 1: 'important commit message' tags: empty-important qbase
315 315 |/
316 316 o 0: 'a' tags: qparent
317 317
318 318
319 319 Rebase bar (make sure series order is preserved and empty-important also is
320 320 removed from the series):
321 321
322 322 $ hg qseries
323 323 guarded
324 324 empty-important
325 325 bar
326 326 foo
327 327 $ [ -f .hg/patches/empty-important ]
328 328 $ hg -q rebase -d 2
329 329 $ hg qseries
330 330 guarded
331 331 bar
332 332 foo
333 333 $ [ -f .hg/patches/empty-important ]
334 334 [1]
335 335
336 336 $ hg qguard -l
337 337 guarded: +guarded
338 338 bar: +baz
339 339 foo: +baz
340 340
341 341 $ hg tglog
342 342 @ 2:* '[mq]: bar' tags: bar qbase qtip tip (glob)
343 343 |
344 344 o 1:* 'b' tags: qparent (glob)
345 345 |
346 346 o 0:* 'a' tags: (glob)
347 347
348 348 $ cd ..
@@ -1,462 +1,462 b''
1 1 $ cat >> $HGRCPATH <<EOF
2 2 > [extensions]
3 3 > rebase=
4 4 >
5 5 > [phases]
6 6 > publish=False
7 7 >
8 8 > [alias]
9 9 > tglog = log -G --template "{rev}: '{desc}' {branches}\n"
10 10 > EOF
11 11
12 12
13 13 $ hg init a
14 14 $ cd a
15 15 $ hg unbundle "$TESTDIR/bundles/rebase.hg"
16 16 adding changesets
17 17 adding manifests
18 18 adding file changes
19 19 added 8 changesets with 7 changes to 7 files (+2 heads)
20 20 (run 'hg heads' to see heads, 'hg merge' to merge)
21 21 $ hg up tip
22 22 3 files updated, 0 files merged, 0 files removed, 0 files unresolved
23 23
24 24 $ echo I > I
25 25 $ hg ci -AmI
26 26 adding I
27 27
28 28 $ hg tglog
29 29 @ 8: 'I'
30 30 |
31 31 o 7: 'H'
32 32 |
33 33 | o 6: 'G'
34 34 |/|
35 35 o | 5: 'F'
36 36 | |
37 37 | o 4: 'E'
38 38 |/
39 39 | o 3: 'D'
40 40 | |
41 41 | o 2: 'C'
42 42 | |
43 43 | o 1: 'B'
44 44 |/
45 45 o 0: 'A'
46 46
47 47 $ cd ..
48 48
49 49
50 50 These fail:
51 51
52 52 $ hg clone -q -u . a a1
53 53 $ cd a1
54 54
55 55 $ hg rebase -s 8 -d 7
56 56 nothing to rebase
57 57 [1]
58 58
59 59 $ hg rebase --continue --abort
60 60 abort: cannot use both abort and continue
61 61 [255]
62 62
63 63 $ hg rebase --continue --collapse
64 64 abort: cannot use collapse with continue or abort
65 65 [255]
66 66
67 67 $ hg rebase --continue --dest 4
68 68 abort: abort and continue do not allow specifying revisions
69 69 [255]
70 70
71 71 $ hg rebase --base 5 --source 4
72 72 abort: cannot specify both a source and a base
73 73 [255]
74 74
75 75 $ hg rebase --rev 5 --source 4
76 76 abort: cannot specify both a revision and a source
77 77 [255]
78 78 $ hg rebase --base 5 --rev 4
79 79 abort: cannot specify both a revision and a base
80 80 [255]
81 81
82 82 $ hg rebase --rev '1 & !1'
83 83 empty "rev" revision set - nothing to rebase
84 84 [1]
85 85
86 86 $ hg rebase --source '1 & !1'
87 87 empty "source" revision set - nothing to rebase
88 88 [1]
89 89
90 90 $ hg rebase --base '1 & !1'
91 91 empty "base" revision set - can't compute rebase set
92 92 [1]
93 93
94 94 $ hg rebase
95 95 nothing to rebase - working directory parent is also destination
96 96 [1]
97 97
98 98 $ hg rebase -b.
99 99 nothing to rebase - e7ec4e813ba6 is both "base" and destination
100 100 [1]
101 101
102 102 $ hg up -q 7
103 103
104 104 $ hg rebase --traceback
105 105 nothing to rebase - working directory parent is already an ancestor of destination e7ec4e813ba6
106 106 [1]
107 107
108 108 $ hg rebase -b.
109 109 nothing to rebase - "base" 02de42196ebe is already an ancestor of destination e7ec4e813ba6
110 110 [1]
111 111
112 112 $ hg rebase --dest '1 & !1'
113 113 abort: empty revision set
114 114 [255]
115 115
116 116 These work:
117 117
118 118 Rebase with no arguments (from 3 onto 8):
119 119
120 120 $ hg up -q -C 3
121 121
122 122 $ hg rebase
123 123 saved backup bundle to $TESTTMP/a1/.hg/strip-backup/*-backup.hg (glob)
124 124
125 125 $ hg tglog
126 126 @ 8: 'D'
127 127 |
128 128 o 7: 'C'
129 129 |
130 130 o 6: 'B'
131 131 |
132 132 o 5: 'I'
133 133 |
134 134 o 4: 'H'
135 135 |
136 136 | o 3: 'G'
137 137 |/|
138 138 o | 2: 'F'
139 139 | |
140 140 | o 1: 'E'
141 141 |/
142 142 o 0: 'A'
143 143
144 144 Try to rollback after a rebase (fail):
145 145
146 146 $ hg rollback
147 147 no rollback information available
148 148 [1]
149 149
150 150 $ cd ..
151 151
152 152 Rebase with base == '.' => same as no arguments (from 3 onto 8):
153 153
154 154 $ hg clone -q -u 3 a a2
155 155 $ cd a2
156 156
157 157 $ hg rebase --base .
158 158 saved backup bundle to $TESTTMP/a2/.hg/strip-backup/*-backup.hg (glob)
159 159
160 160 $ hg tglog
161 161 @ 8: 'D'
162 162 |
163 163 o 7: 'C'
164 164 |
165 165 o 6: 'B'
166 166 |
167 167 o 5: 'I'
168 168 |
169 169 o 4: 'H'
170 170 |
171 171 | o 3: 'G'
172 172 |/|
173 173 o | 2: 'F'
174 174 | |
175 175 | o 1: 'E'
176 176 |/
177 177 o 0: 'A'
178 178
179 179 $ cd ..
180 180
181 181
182 182 Rebase with dest == branch(.) => same as no arguments (from 3 onto 8):
183 183
184 184 $ hg clone -q -u 3 a a3
185 185 $ cd a3
186 186
187 187 $ hg rebase --dest 'branch(.)'
188 188 saved backup bundle to $TESTTMP/a3/.hg/strip-backup/*-backup.hg (glob)
189 189
190 190 $ hg tglog
191 191 @ 8: 'D'
192 192 |
193 193 o 7: 'C'
194 194 |
195 195 o 6: 'B'
196 196 |
197 197 o 5: 'I'
198 198 |
199 199 o 4: 'H'
200 200 |
201 201 | o 3: 'G'
202 202 |/|
203 203 o | 2: 'F'
204 204 | |
205 205 | o 1: 'E'
206 206 |/
207 207 o 0: 'A'
208 208
209 209 $ cd ..
210 210
211 211
212 212 Specify only source (from 2 onto 8):
213 213
214 214 $ hg clone -q -u . a a4
215 215 $ cd a4
216 216
217 217 $ hg rebase --source 'desc("C")'
218 218 saved backup bundle to $TESTTMP/a4/.hg/strip-backup/*-backup.hg (glob)
219 219
220 220 $ hg tglog
221 221 o 8: 'D'
222 222 |
223 223 o 7: 'C'
224 224 |
225 225 @ 6: 'I'
226 226 |
227 227 o 5: 'H'
228 228 |
229 229 | o 4: 'G'
230 230 |/|
231 231 o | 3: 'F'
232 232 | |
233 233 | o 2: 'E'
234 234 |/
235 235 | o 1: 'B'
236 236 |/
237 237 o 0: 'A'
238 238
239 239 $ cd ..
240 240
241 241
242 242 Specify only dest (from 3 onto 6):
243 243
244 244 $ hg clone -q -u 3 a a5
245 245 $ cd a5
246 246
247 247 $ hg rebase --dest 6
248 248 saved backup bundle to $TESTTMP/a5/.hg/strip-backup/*-backup.hg (glob)
249 249
250 250 $ hg tglog
251 251 @ 8: 'D'
252 252 |
253 253 o 7: 'C'
254 254 |
255 255 o 6: 'B'
256 256 |
257 257 | o 5: 'I'
258 258 | |
259 259 | o 4: 'H'
260 260 | |
261 261 o | 3: 'G'
262 262 |\|
263 263 | o 2: 'F'
264 264 | |
265 265 o | 1: 'E'
266 266 |/
267 267 o 0: 'A'
268 268
269 269 $ cd ..
270 270
271 271
272 272 Specify only base (from 1 onto 8):
273 273
274 274 $ hg clone -q -u . a a6
275 275 $ cd a6
276 276
277 277 $ hg rebase --base 'desc("D")'
278 278 saved backup bundle to $TESTTMP/a6/.hg/strip-backup/*-backup.hg (glob)
279 279
280 280 $ hg tglog
281 281 o 8: 'D'
282 282 |
283 283 o 7: 'C'
284 284 |
285 285 o 6: 'B'
286 286 |
287 287 @ 5: 'I'
288 288 |
289 289 o 4: 'H'
290 290 |
291 291 | o 3: 'G'
292 292 |/|
293 293 o | 2: 'F'
294 294 | |
295 295 | o 1: 'E'
296 296 |/
297 297 o 0: 'A'
298 298
299 299 $ cd ..
300 300
301 301
302 302 Specify source and dest (from 2 onto 7):
303 303
304 304 $ hg clone -q -u . a a7
305 305 $ cd a7
306 306
307 307 $ hg rebase --source 2 --dest 7
308 308 saved backup bundle to $TESTTMP/a7/.hg/strip-backup/*-backup.hg (glob)
309 309
310 310 $ hg tglog
311 311 o 8: 'D'
312 312 |
313 313 o 7: 'C'
314 314 |
315 315 | @ 6: 'I'
316 316 |/
317 317 o 5: 'H'
318 318 |
319 319 | o 4: 'G'
320 320 |/|
321 321 o | 3: 'F'
322 322 | |
323 323 | o 2: 'E'
324 324 |/
325 325 | o 1: 'B'
326 326 |/
327 327 o 0: 'A'
328 328
329 329 $ cd ..
330 330
331 331
332 332 Specify base and dest (from 1 onto 7):
333 333
334 334 $ hg clone -q -u . a a8
335 335 $ cd a8
336 336
337 337 $ hg rebase --base 3 --dest 7
338 338 saved backup bundle to $TESTTMP/a8/.hg/strip-backup/*-backup.hg (glob)
339 339
340 340 $ hg tglog
341 341 o 8: 'D'
342 342 |
343 343 o 7: 'C'
344 344 |
345 345 o 6: 'B'
346 346 |
347 347 | @ 5: 'I'
348 348 |/
349 349 o 4: 'H'
350 350 |
351 351 | o 3: 'G'
352 352 |/|
353 353 o | 2: 'F'
354 354 | |
355 355 | o 1: 'E'
356 356 |/
357 357 o 0: 'A'
358 358
359 359 $ cd ..
360 360
361 361
362 362 Specify only revs (from 2 onto 8)
363 363
364 364 $ hg clone -q -u . a a9
365 365 $ cd a9
366 366
367 367 $ hg rebase --rev 'desc("C")::'
368 368 saved backup bundle to $TESTTMP/a9/.hg/strip-backup/*-backup.hg (glob)
369 369
370 370 $ hg tglog
371 371 o 8: 'D'
372 372 |
373 373 o 7: 'C'
374 374 |
375 375 @ 6: 'I'
376 376 |
377 377 o 5: 'H'
378 378 |
379 379 | o 4: 'G'
380 380 |/|
381 381 o | 3: 'F'
382 382 | |
383 383 | o 2: 'E'
384 384 |/
385 385 | o 1: 'B'
386 386 |/
387 387 o 0: 'A'
388 388
389 389 $ cd ..
390 390
391 391 Test --tool parameter:
392 392
393 393 $ hg init b
394 394 $ cd b
395 395
396 396 $ echo c1 > c1
397 397 $ hg ci -Am c1
398 398 adding c1
399 399
400 400 $ echo c2 > c2
401 401 $ hg ci -Am c2
402 402 adding c2
403 403
404 404 $ hg up -q 0
405 405 $ echo c2b > c2
406 406 $ hg ci -Am c2b
407 407 adding c2
408 408 created new head
409 409
410 410 $ cd ..
411 411
412 412 $ hg clone -q -u . b b1
413 413 $ cd b1
414 414
415 415 $ hg rebase -s 2 -d 1 --tool internal:local
416 416 saved backup bundle to $TESTTMP/b1/.hg/strip-backup/*-backup.hg (glob)
417 417
418 418 $ hg cat c2
419 419 c2
420 420
421 421 $ cd ..
422 422
423 423
424 424 $ hg clone -q -u . b b2
425 425 $ cd b2
426 426
427 427 $ hg rebase -s 2 -d 1 --tool internal:other
428 428 saved backup bundle to $TESTTMP/b2/.hg/strip-backup/*-backup.hg (glob)
429 429
430 430 $ hg cat c2
431 431 c2b
432 432
433 433 $ cd ..
434 434
435 435
436 436 $ hg clone -q -u . b b3
437 437 $ cd b3
438 438
439 439 $ hg rebase -s 2 -d 1 --tool internal:fail
440 440 unresolved conflicts (see hg resolve, then hg rebase --continue)
441 441 [1]
442 442
443 443 $ hg summary
444 444 parent: 1:56daeba07f4b
445 445 c2
446 446 parent: 2:e4e3f3546619 tip
447 447 c2b
448 448 branch: default
449 449 commit: 1 modified, 1 unresolved (merge)
450 450 update: (current)
451 451 rebase: 0 rebased, 1 remaining (rebase --continue)
452 452
453 453 $ hg resolve -l
454 454 U c2
455 455
456 456 $ hg resolve -m c2
457 no unresolved files; you may continue your unfinished operation
457 no more unresolved files
458 458 $ hg rebase -c --tool internal:fail
459 459 tool option will be ignored
460 460 saved backup bundle to $TESTTMP/b3/.hg/strip-backup/*-backup.hg (glob)
461 461
462 462 $ cd ..
@@ -1,60 +1,60 b''
1 1 test that a commit clears the merge state.
2 2
3 3 $ hg init repo
4 4 $ cd repo
5 5
6 6 $ echo foo > file
7 7 $ hg commit -Am 'add file'
8 8 adding file
9 9
10 10 $ echo bar >> file
11 11 $ hg commit -Am 'append bar'
12 12
13 13
14 14 create a second head
15 15
16 16 $ hg up -C 0
17 17 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
18 18 $ echo baz >> file
19 19 $ hg commit -Am 'append baz'
20 20 created new head
21 21
22 22 failing merge
23 23
24 24 $ hg merge --tool=internal:fail
25 25 0 files updated, 0 files merged, 0 files removed, 1 files unresolved
26 26 use 'hg resolve' to retry unresolved file merges or 'hg update -C .' to abandon
27 27 [1]
28 28
29 29 resolve -l should contain an unresolved entry
30 30
31 31 $ hg resolve -l
32 32 U file
33 33
34 34 resolving an unknown path emits a warning
35 35 $ hg resolve -m does-not-exist
36 36 arguments do not match paths that need resolved
37 37
38 38 resolve the failure
39 39
40 40 $ echo resolved > file
41 41 $ hg resolve -m file
42 no unresolved files; you may continue your unfinished operation
42 no more unresolved files
43 43 $ hg commit -m 'resolved'
44 44
45 45 resolve -l should error since no merge in progress
46 46
47 47 $ hg resolve -l
48 48 abort: resolve command not applicable when not merging
49 49 [255]
50 50
51 51 test crashed merge with empty mergestate
52 52
53 53 $ mkdir .hg/merge
54 54 $ touch .hg/merge/state
55 55
56 56 resolve -l, should be empty
57 57
58 58 $ hg resolve -l
59 59
60 60 $ cd ..
@@ -1,669 +1,669 b''
1 1 $ echo "[extensions]" >> $HGRCPATH
2 2 $ echo "mq=" >> $HGRCPATH
3 3 $ echo "shelve=" >> $HGRCPATH
4 4 $ echo "[defaults]" >> $HGRCPATH
5 5 $ echo "diff = --nodates --git" >> $HGRCPATH
6 6 $ echo "qnew = --date '0 0'" >> $HGRCPATH
7 7
8 8 $ hg init repo
9 9 $ cd repo
10 10 $ mkdir a b
11 11 $ echo a > a/a
12 12 $ echo b > b/b
13 13 $ echo c > c
14 14 $ echo d > d
15 15 $ echo x > x
16 16 $ hg addremove -q
17 17
18 18 shelving in an empty repo should be possible
19 19
20 20 $ hg shelve
21 21 shelved as default
22 22 0 files updated, 0 files merged, 5 files removed, 0 files unresolved
23 23
24 24 $ hg unshelve
25 25 unshelving change 'default'
26 26
27 27 $ hg commit -q -m 'initial commit'
28 28
29 29 $ hg shelve
30 30 nothing changed
31 31 [1]
32 32
33 33 create an mq patch - shelving should work fine with a patch applied
34 34
35 35 $ echo n > n
36 36 $ hg add n
37 37 $ hg commit n -m second
38 38 $ hg qnew second.patch
39 39
40 40 shelve a change that we will delete later
41 41
42 42 $ echo a >> a/a
43 43 $ hg shelve
44 44 shelved as default
45 45 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
46 46
47 47 set up some more complex changes to shelve
48 48
49 49 $ echo a >> a/a
50 50 $ hg mv b b.rename
51 51 moving b/b to b.rename/b (glob)
52 52 $ hg cp c c.copy
53 53 $ hg status -C
54 54 M a/a
55 55 A b.rename/b
56 56 b/b
57 57 A c.copy
58 58 c
59 59 R b/b
60 60
61 61 prevent some foot-shooting
62 62
63 63 $ hg shelve -n foo/bar
64 64 abort: shelved change names may not contain slashes
65 65 [255]
66 66 $ hg shelve -n .baz
67 67 abort: shelved change names may not start with '.'
68 68 [255]
69 69
70 70 the common case - no options or filenames
71 71
72 72 $ hg shelve
73 73 shelved as default-01
74 74 2 files updated, 0 files merged, 2 files removed, 0 files unresolved
75 75 $ hg status -C
76 76
77 77 ensure that our shelved changes exist
78 78
79 79 $ hg shelve -l
80 80 default-01 (*) changes to '[mq]: second.patch' (glob)
81 81 default (*) changes to '[mq]: second.patch' (glob)
82 82
83 83 $ hg shelve -l -p default
84 84 default (*) changes to '[mq]: second.patch' (glob)
85 85
86 86 diff --git a/a/a b/a/a
87 87 --- a/a/a
88 88 +++ b/a/a
89 89 @@ -1,1 +1,2 @@
90 90 a
91 91 +a
92 92
93 93 delete our older shelved change
94 94
95 95 $ hg shelve -d default
96 96 $ hg qfinish -a -q
97 97
98 98 local edits should not prevent a shelved change from applying
99 99
100 100 $ printf "z\na\n" > a/a
101 101 $ hg unshelve --keep
102 102 unshelving change 'default-01'
103 103 temporarily committing pending changes (restore with 'hg unshelve --abort')
104 104 rebasing shelved changes
105 105 merging a/a
106 106
107 107 $ hg revert --all -q
108 108 $ rm a/a.orig b.rename/b c.copy
109 109
110 110 apply it and make sure our state is as expected
111 111
112 112 $ hg unshelve
113 113 unshelving change 'default-01'
114 114 $ hg status -C
115 115 M a/a
116 116 A b.rename/b
117 117 b/b
118 118 A c.copy
119 119 c
120 120 R b/b
121 121 $ hg shelve -l
122 122
123 123 $ hg unshelve
124 124 abort: no shelved changes to apply!
125 125 [255]
126 126 $ hg unshelve foo
127 127 abort: shelved change 'foo' not found
128 128 [255]
129 129
130 130 named shelves, specific filenames, and "commit messages" should all work
131 131
132 132 $ hg status -C
133 133 M a/a
134 134 A b.rename/b
135 135 b/b
136 136 A c.copy
137 137 c
138 138 R b/b
139 139 $ hg shelve -q -n wibble -m wat a
140 140
141 141 expect "a" to no longer be present, but status otherwise unchanged
142 142
143 143 $ hg status -C
144 144 A b.rename/b
145 145 b/b
146 146 A c.copy
147 147 c
148 148 R b/b
149 149 $ hg shelve -l --stat
150 150 wibble (*) wat (glob)
151 151 a/a | 1 +
152 152 1 files changed, 1 insertions(+), 0 deletions(-)
153 153
154 154 and now "a/a" should reappear
155 155
156 156 $ cd a
157 157 $ hg unshelve -q wibble
158 158 $ cd ..
159 159 $ hg status -C
160 160 M a/a
161 161 A b.rename/b
162 162 b/b
163 163 A c.copy
164 164 c
165 165 R b/b
166 166
167 167 cause unshelving to result in a merge with 'a' conflicting
168 168
169 169 $ hg shelve -q
170 170 $ echo c>>a/a
171 171 $ hg commit -m second
172 172 $ hg tip --template '{files}\n'
173 173 a/a
174 174
175 175 add an unrelated change that should be preserved
176 176
177 177 $ mkdir foo
178 178 $ echo foo > foo/foo
179 179 $ hg add foo/foo
180 180
181 181 force a conflicted merge to occur
182 182
183 183 $ hg unshelve
184 184 unshelving change 'default'
185 185 temporarily committing pending changes (restore with 'hg unshelve --abort')
186 186 rebasing shelved changes
187 187 merging a/a
188 188 warning: conflicts during merge.
189 189 merging a/a incomplete! (edit conflicts, then use 'hg resolve --mark')
190 190 unresolved conflicts (see 'hg resolve', then 'hg unshelve --continue')
191 191 [1]
192 192
193 193 ensure that we have a merge with unresolved conflicts
194 194
195 195 $ hg heads -q --template '{rev}\n'
196 196 5
197 197 4
198 198 $ hg parents -q --template '{rev}\n'
199 199 4
200 200 5
201 201 $ hg status
202 202 M a/a
203 203 M b.rename/b
204 204 M c.copy
205 205 R b/b
206 206 ? a/a.orig
207 207 $ hg diff
208 208 diff --git a/a/a b/a/a
209 209 --- a/a/a
210 210 +++ b/a/a
211 211 @@ -1,2 +1,6 @@
212 212 a
213 213 +<<<<<<< local
214 214 c
215 215 +=======
216 216 +a
217 217 +>>>>>>> other
218 218 diff --git a/b.rename/b b/b.rename/b
219 219 new file mode 100644
220 220 --- /dev/null
221 221 +++ b/b.rename/b
222 222 @@ -0,0 +1,1 @@
223 223 +b
224 224 diff --git a/b/b b/b/b
225 225 deleted file mode 100644
226 226 --- a/b/b
227 227 +++ /dev/null
228 228 @@ -1,1 +0,0 @@
229 229 -b
230 230 diff --git a/c.copy b/c.copy
231 231 new file mode 100644
232 232 --- /dev/null
233 233 +++ b/c.copy
234 234 @@ -0,0 +1,1 @@
235 235 +c
236 236 $ hg resolve -l
237 237 U a/a
238 238
239 239 $ hg shelve
240 240 abort: unshelve already in progress
241 241 (use 'hg unshelve --continue' or 'hg unshelve --abort')
242 242 [255]
243 243
244 244 abort the unshelve and be happy
245 245
246 246 $ hg status
247 247 M a/a
248 248 M b.rename/b
249 249 M c.copy
250 250 R b/b
251 251 ? a/a.orig
252 252 $ hg unshelve -a
253 253 rebase aborted
254 254 unshelve of 'default' aborted
255 255 $ hg heads -q
256 256 3:2e69b451d1ea
257 257 $ hg parents
258 258 changeset: 3:2e69b451d1ea
259 259 tag: tip
260 260 user: test
261 261 date: Thu Jan 01 00:00:00 1970 +0000
262 262 summary: second
263 263
264 264 $ hg resolve -l
265 265 abort: resolve command not applicable when not merging
266 266 [255]
267 267 $ hg status
268 268 A foo/foo
269 269 ? a/a.orig
270 270
271 271 try to continue with no unshelve underway
272 272
273 273 $ hg unshelve -c
274 274 abort: no unshelve operation underway
275 275 [255]
276 276 $ hg status
277 277 A foo/foo
278 278 ? a/a.orig
279 279
280 280 redo the unshelve to get a conflict
281 281
282 282 $ hg unshelve -q
283 283 warning: conflicts during merge.
284 284 merging a/a incomplete! (edit conflicts, then use 'hg resolve --mark')
285 285 unresolved conflicts (see 'hg resolve', then 'hg unshelve --continue')
286 286 [1]
287 287
288 288 attempt to continue
289 289
290 290 $ hg unshelve -c
291 291 abort: unresolved conflicts, can't continue
292 292 (see 'hg resolve', then 'hg unshelve --continue')
293 293 [255]
294 294
295 295 $ hg revert -r . a/a
296 296 $ hg resolve -m a/a
297 no unresolved files; you may continue your unfinished operation
297 no more unresolved files
298 298
299 299 $ hg commit -m 'commit while unshelve in progress'
300 300 abort: unshelve already in progress
301 301 (use 'hg unshelve --continue' or 'hg unshelve --abort')
302 302 [255]
303 303
304 304 $ hg unshelve -c
305 305 unshelve of 'default' complete
306 306
307 307 ensure the repo is as we hope
308 308
309 309 $ hg parents
310 310 changeset: 3:2e69b451d1ea
311 311 tag: tip
312 312 user: test
313 313 date: Thu Jan 01 00:00:00 1970 +0000
314 314 summary: second
315 315
316 316 $ hg heads -q
317 317 3:2e69b451d1ea
318 318
319 319 $ hg status -C
320 320 A b.rename/b
321 321 b/b
322 322 A c.copy
323 323 c
324 324 A foo/foo
325 325 R b/b
326 326 ? a/a.orig
327 327
328 328 there should be no shelves left
329 329
330 330 $ hg shelve -l
331 331
332 332 #if execbit
333 333
334 334 ensure that metadata-only changes are shelved
335 335
336 336 $ chmod +x a/a
337 337 $ hg shelve -q -n execbit a/a
338 338 $ hg status a/a
339 339 $ hg unshelve -q execbit
340 340 $ hg status a/a
341 341 M a/a
342 342 $ hg revert a/a
343 343
344 344 #endif
345 345
346 346 #if symlink
347 347
348 348 $ rm a/a
349 349 $ ln -s foo a/a
350 350 $ hg shelve -q -n symlink a/a
351 351 $ hg status a/a
352 352 $ hg unshelve -q symlink
353 353 $ hg status a/a
354 354 M a/a
355 355 $ hg revert a/a
356 356
357 357 #endif
358 358
359 359 set up another conflict between a commit and a shelved change
360 360
361 361 $ hg revert -q -C -a
362 362 $ rm a/a.orig b.rename/b c.copy
363 363 $ echo a >> a/a
364 364 $ hg shelve -q
365 365 $ echo x >> a/a
366 366 $ hg ci -m 'create conflict'
367 367 $ hg add foo/foo
368 368
369 369 if we resolve a conflict while unshelving, the unshelve should succeed
370 370
371 371 $ HGMERGE=true hg unshelve
372 372 unshelving change 'default'
373 373 temporarily committing pending changes (restore with 'hg unshelve --abort')
374 374 rebasing shelved changes
375 375 merging a/a
376 376 $ hg parents -q
377 377 4:33f7f61e6c5e
378 378 $ hg shelve -l
379 379 $ hg status
380 380 A foo/foo
381 381 $ cat a/a
382 382 a
383 383 c
384 384 x
385 385
386 386 test keep and cleanup
387 387
388 388 $ hg shelve
389 389 shelved as default
390 390 0 files updated, 0 files merged, 1 files removed, 0 files unresolved
391 391 $ hg shelve --list
392 392 default (*) changes to 'create conflict' (glob)
393 393 $ hg unshelve --keep
394 394 unshelving change 'default'
395 395 $ hg shelve --list
396 396 default (*) changes to 'create conflict' (glob)
397 397 $ hg shelve --cleanup
398 398 $ hg shelve --list
399 399
400 400 test bookmarks
401 401
402 402 $ hg bookmark test
403 403 $ hg bookmark
404 404 * test 4:33f7f61e6c5e
405 405 $ hg shelve
406 406 shelved as test
407 407 0 files updated, 0 files merged, 1 files removed, 0 files unresolved
408 408 $ hg bookmark
409 409 * test 4:33f7f61e6c5e
410 410 $ hg unshelve
411 411 unshelving change 'test'
412 412 $ hg bookmark
413 413 * test 4:33f7f61e6c5e
414 414
415 415 shelve should still work even if mq is disabled
416 416
417 417 $ hg --config extensions.mq=! shelve
418 418 shelved as test
419 419 0 files updated, 0 files merged, 1 files removed, 0 files unresolved
420 420 $ hg --config extensions.mq=! shelve --list
421 421 test (*) changes to 'create conflict' (glob)
422 422 $ hg --config extensions.mq=! unshelve
423 423 unshelving change 'test'
424 424
425 425 shelve should leave dirstate clean (issue 4055)
426 426
427 427 $ cd ..
428 428 $ hg init shelverebase
429 429 $ cd shelverebase
430 430 $ printf 'x\ny\n' > x
431 431 $ echo z > z
432 432 $ hg commit -Aqm xy
433 433 $ echo z >> x
434 434 $ hg commit -Aqm z
435 435 $ hg up 0
436 436 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
437 437 $ printf 'a\nx\ny\nz\n' > x
438 438 $ hg commit -Aqm xyz
439 439 $ echo c >> z
440 440 $ hg shelve
441 441 shelved as default
442 442 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
443 443 $ hg rebase -d 1 --config extensions.rebase=
444 444 merging x
445 445 saved backup bundle to $TESTTMP/shelverebase/.hg/strip-backup/323bfa07f744-backup.hg (glob)
446 446 $ hg unshelve
447 447 unshelving change 'default'
448 448 rebasing shelved changes
449 449 $ hg status
450 450 M z
451 451
452 452 $ cd ..
453 453
454 454 shelve should only unshelve pending changes (issue 4068)
455 455
456 456 $ hg init onlypendingchanges
457 457 $ cd onlypendingchanges
458 458 $ touch a
459 459 $ hg ci -Aqm a
460 460 $ touch b
461 461 $ hg ci -Aqm b
462 462 $ hg up -q 0
463 463 $ touch c
464 464 $ hg ci -Aqm c
465 465
466 466 $ touch d
467 467 $ hg add d
468 468 $ hg shelve
469 469 shelved as default
470 470 0 files updated, 0 files merged, 1 files removed, 0 files unresolved
471 471 $ hg up -q 1
472 472 $ hg unshelve
473 473 unshelving change 'default'
474 474 rebasing shelved changes
475 475 $ hg status
476 476 A d
477 477
478 478 unshelve should work on an ancestor of the original commit
479 479
480 480 $ hg shelve
481 481 shelved as default
482 482 0 files updated, 0 files merged, 1 files removed, 0 files unresolved
483 483 $ hg up 0
484 484 0 files updated, 0 files merged, 1 files removed, 0 files unresolved
485 485 $ hg unshelve
486 486 unshelving change 'default'
487 487 rebasing shelved changes
488 488 $ hg status
489 489 A d
490 490
491 491 test bug 4073 we need to enable obsolete markers for it
492 492
493 493 $ cat > ../obs.py << EOF
494 494 > import mercurial.obsolete
495 495 > mercurial.obsolete._enabled = True
496 496 > EOF
497 497 $ echo '[extensions]' >> $HGRCPATH
498 498 $ echo "obs=${TESTTMP}/obs.py" >> $HGRCPATH
499 499 $ hg shelve
500 500 shelved as default
501 501 0 files updated, 0 files merged, 1 files removed, 0 files unresolved
502 502 $ hg debugobsolete `hg --debug id -i -r 1`
503 503 $ hg unshelve
504 504 unshelving change 'default'
505 505
506 506 unshelve should leave unknown files alone (issue4113)
507 507
508 508 $ echo e > e
509 509 $ hg shelve
510 510 shelved as default
511 511 0 files updated, 0 files merged, 1 files removed, 0 files unresolved
512 512 $ hg status
513 513 ? e
514 514 $ hg unshelve
515 515 unshelving change 'default'
516 516 $ hg status
517 517 A d
518 518 ? e
519 519 $ cat e
520 520 e
521 521
522 522 unshelve should keep a copy of unknown files
523 523
524 524 $ hg add e
525 525 $ hg shelve
526 526 shelved as default
527 527 0 files updated, 0 files merged, 2 files removed, 0 files unresolved
528 528 $ echo z > e
529 529 $ hg unshelve
530 530 unshelving change 'default'
531 531 $ cat e
532 532 e
533 533 $ cat e.orig
534 534 z
535 535
536 536
537 537 unshelve and conflicts with tracked and untracked files
538 538
539 539 preparing:
540 540
541 541 $ rm *.orig
542 542 $ hg ci -qm 'commit stuff'
543 543 $ hg phase -p null:
544 544
545 545 no other changes - no merge:
546 546
547 547 $ echo f > f
548 548 $ hg add f
549 549 $ hg shelve
550 550 shelved as default
551 551 0 files updated, 0 files merged, 1 files removed, 0 files unresolved
552 552 $ echo g > f
553 553 $ hg unshelve
554 554 unshelving change 'default'
555 555 $ hg st
556 556 A f
557 557 ? f.orig
558 558 $ cat f
559 559 f
560 560 $ cat f.orig
561 561 g
562 562
563 563 other uncommitted changes - merge:
564 564
565 565 $ hg st
566 566 A f
567 567 ? f.orig
568 568 $ hg shelve
569 569 shelved as default
570 570 0 files updated, 0 files merged, 1 files removed, 0 files unresolved
571 571 $ hg log -G --template '{rev} {desc|firstline} {author}' -R bundle://.hg/shelved/default.hg -r 'bundle()'
572 572 o 4 changes to 'commit stuff' shelve@localhost
573 573 |
574 574 $ hg log -G --template '{rev} {desc|firstline} {author}'
575 575 @ 3 commit stuff test
576 576 |
577 577 | o 2 c test
578 578 |/
579 579 o 0 a test
580 580
581 581 $ mv f.orig f
582 582 $ echo 1 > a
583 583 $ hg unshelve --date '1073741824 0'
584 584 unshelving change 'default'
585 585 temporarily committing pending changes (restore with 'hg unshelve --abort')
586 586 rebasing shelved changes
587 587 merging f
588 588 warning: conflicts during merge.
589 589 merging f incomplete! (edit conflicts, then use 'hg resolve --mark')
590 590 unresolved conflicts (see 'hg resolve', then 'hg unshelve --continue')
591 591 [1]
592 592 $ hg log -G --template '{rev} {desc|firstline} {author} {date|isodate}'
593 593 @ 5 changes to 'commit stuff' shelve@localhost 1970-01-01 00:00 +0000
594 594 |
595 595 | @ 4 pending changes temporary commit shelve@localhost 2004-01-10 13:37 +0000
596 596 |/
597 597 o 3 commit stuff test 1970-01-01 00:00 +0000
598 598 |
599 599 | o 2 c test 1970-01-01 00:00 +0000
600 600 |/
601 601 o 0 a test 1970-01-01 00:00 +0000
602 602
603 603 $ hg st
604 604 M f
605 605 ? f.orig
606 606 $ cat f
607 607 <<<<<<< local
608 608 g
609 609 =======
610 610 f
611 611 >>>>>>> other
612 612 $ cat f.orig
613 613 g
614 614 $ hg unshelve --abort
615 615 rebase aborted
616 616 unshelve of 'default' aborted
617 617 $ hg st
618 618 M a
619 619 ? f.orig
620 620 $ cat f.orig
621 621 g
622 622 $ hg unshelve
623 623 unshelving change 'default'
624 624 temporarily committing pending changes (restore with 'hg unshelve --abort')
625 625 rebasing shelved changes
626 626 $ hg st
627 627 M a
628 628 A f
629 629 ? f.orig
630 630
631 631 other committed changes - merge:
632 632
633 633 $ hg shelve f
634 634 shelved as default
635 635 0 files updated, 0 files merged, 1 files removed, 0 files unresolved
636 636 $ hg ci a -m 'intermediate other change'
637 637 $ mv f.orig f
638 638 $ hg unshelve
639 639 unshelving change 'default'
640 640 rebasing shelved changes
641 641 merging f
642 642 warning: conflicts during merge.
643 643 merging f incomplete! (edit conflicts, then use 'hg resolve --mark')
644 644 unresolved conflicts (see 'hg resolve', then 'hg unshelve --continue')
645 645 [1]
646 646 $ hg st
647 647 M f
648 648 ? f.orig
649 649 $ cat f
650 650 <<<<<<< local
651 651 g
652 652 =======
653 653 f
654 654 >>>>>>> other
655 655 $ cat f.orig
656 656 g
657 657 $ hg unshelve --abort
658 658 rebase aborted
659 659 no changes needed to a
660 660 no changes needed to d
661 661 no changes needed to e
662 662 unshelve of 'default' aborted
663 663 $ hg st
664 664 ? f.orig
665 665 $ cat f.orig
666 666 g
667 667 $ hg shelve --delete default
668 668
669 669 $ cd ..
General Comments 0
You need to be logged in to leave comments. Login now