comparison mercurial/scmutil.py @ 34005:5e83a8fe6bc4

rebase: initial support for multiple destinations This patch defines `SRC` (a single source revision) and `ALLSRC` (all source revisions) to be valid names in `--dest` revset if `--src` or `--rev` is used. So destination could be defined differently according to source revisions. The names are capitalized to make it clear they are "dynamically defined", distinguishable from normal revsets (Thanks Augie for the suggestion). This is useful, for example, `-r 'orphan()' -d 'calc-dest(SRC)'` to solve instability, which seems to be a highly wanted feature. The feature is not completed, namely if `-d` overlaps with `-r`, things could go wrong. A later patch will handle that case. The feature is also gated by `experimental.rebase.multidest` config option which is default off. Differential Revision: https://phab.mercurial-scm.org/D469
author Jun Wu <quark@fb.com>
date Tue, 29 Aug 2017 17:27:37 -0700
parents 2cd5aba5e1d2
children d5b2beca16c0
comparison
equal deleted inserted replaced
34004:af609bb3487f 34005:5e83a8fe6bc4
400 rev = ctx.rev() 400 rev = ctx.rev()
401 if rev is None: 401 if rev is None:
402 return wdirrev 402 return wdirrev
403 return rev 403 return rev
404 404
405 def revsingle(repo, revspec, default='.'): 405 def revsingle(repo, revspec, default='.', localalias=None):
406 if not revspec and revspec != 0: 406 if not revspec and revspec != 0:
407 return repo[default] 407 return repo[default]
408 408
409 l = revrange(repo, [revspec]) 409 l = revrange(repo, [revspec], localalias=localalias)
410 if not l: 410 if not l:
411 raise error.Abort(_('empty revision set')) 411 raise error.Abort(_('empty revision set'))
412 return repo[l.last()] 412 return repo[l.last()]
413 413
414 def _pairspec(revspec): 414 def _pairspec(revspec):
443 if first == second and len(revs) == 1 and not _pairspec(revs[0]): 443 if first == second and len(revs) == 1 and not _pairspec(revs[0]):
444 return repo.lookup(first), None 444 return repo.lookup(first), None
445 445
446 return repo.lookup(first), repo.lookup(second) 446 return repo.lookup(first), repo.lookup(second)
447 447
448 def revrange(repo, specs): 448 def revrange(repo, specs, localalias=None):
449 """Execute 1 to many revsets and return the union. 449 """Execute 1 to many revsets and return the union.
450 450
451 This is the preferred mechanism for executing revsets using user-specified 451 This is the preferred mechanism for executing revsets using user-specified
452 config options, such as revset aliases. 452 config options, such as revset aliases.
453 453
469 allspecs = [] 469 allspecs = []
470 for spec in specs: 470 for spec in specs:
471 if isinstance(spec, int): 471 if isinstance(spec, int):
472 spec = revsetlang.formatspec('rev(%d)', spec) 472 spec = revsetlang.formatspec('rev(%d)', spec)
473 allspecs.append(spec) 473 allspecs.append(spec)
474 return repo.anyrevs(allspecs, user=True) 474 return repo.anyrevs(allspecs, user=True, localalias=localalias)
475 475
476 def meaningfulparents(repo, ctx): 476 def meaningfulparents(repo, ctx):
477 """Return list of meaningful (or all if debug) parentrevs for rev. 477 """Return list of meaningful (or all if debug) parentrevs for rev.
478 478
479 For merges (two non-nullrev revisions) both parents are meaningful. 479 For merges (two non-nullrev revisions) both parents are meaningful.