Mercurial > public > mercurial-scm > hg-stable
comparison mercurial/revset.py @ 26304:bca60842e22d
update: move default destination into a revset
This is another step toward having "default" destination more clear and unified.
Not all the logic is there because some bookmark related computation happened
elsewhere. It will be moved later.
The function is private because as for the other ones, cleanup is needed before
we can proceed.
author | Pierre-Yves David <pierre-yves.david@fb.com> |
---|---|
date | Fri, 18 Sep 2015 17:23:10 -0700 |
parents | c99b4d6efdd8 |
children | ade5c488d622 |
comparison
equal
deleted
inserted
replaced
26303:c99b4d6efdd8 | 26304:bca60842e22d |
---|---|
522 node = nbhs[-1] | 522 node = nbhs[-1] |
523 else: | 523 else: |
524 node = nbhs[0] | 524 node = nbhs[0] |
525 return subset & baseset([repo[node].rev()]) | 525 return subset & baseset([repo[node].rev()]) |
526 | 526 |
527 def _updatedefaultdest(repo, subset, x): | |
528 # ``_updatedefaultdest()`` | |
529 | |
530 # default destination for update. | |
531 # # XXX: Currently private because I expect the signature to change. | |
532 # # XXX: - taking rev as arguments, | |
533 # # XXX: - bailing out in case of ambiguity vs returning all data. | |
534 getargs(x, 0, 0, _("_updatedefaultdest takes no arguments")) | |
535 # Here is where we should consider bookmarks, divergent bookmarks, | |
536 # foreground changesets (successors), and tip of current branch; | |
537 # but currently we are only checking the branch tips. | |
538 node = None | |
539 wc = repo[None] | |
540 p1 = wc.p1() | |
541 try: | |
542 node = repo.branchtip(wc.branch()) | |
543 except error.RepoLookupError: | |
544 if wc.branch() == 'default': # no default branch! | |
545 node = repo.lookup('tip') # update to tip | |
546 else: | |
547 raise util.Abort(_("branch %s not found") % wc.branch()) | |
548 | |
549 if p1.obsolete() and not p1.children(): | |
550 # allow updating to successors | |
551 successors = obsmod.successorssets(repo, p1.node()) | |
552 | |
553 # behavior of certain cases is as follows, | |
554 # | |
555 # divergent changesets: update to highest rev, similar to what | |
556 # is currently done when there are more than one head | |
557 # (i.e. 'tip') | |
558 # | |
559 # replaced changesets: same as divergent except we know there | |
560 # is no conflict | |
561 # | |
562 # pruned changeset: no update is done; though, we could | |
563 # consider updating to the first non-obsolete parent, | |
564 # similar to what is current done for 'hg prune' | |
565 | |
566 if successors: | |
567 # flatten the list here handles both divergent (len > 1) | |
568 # and the usual case (len = 1) | |
569 successors = [n for sub in successors for n in sub] | |
570 | |
571 # get the max revision for the given successors set, | |
572 # i.e. the 'tip' of a set | |
573 node = repo.revs('max(%ln)', successors).first() | |
574 return subset & baseset([repo[node].rev()]) | |
575 | |
527 def adds(repo, subset, x): | 576 def adds(repo, subset, x): |
528 """``adds(pattern)`` | 577 """``adds(pattern)`` |
529 Changesets that add a file matching pattern. | 578 Changesets that add a file matching pattern. |
530 | 579 |
531 The pattern without explicit kind like ``glob:`` is expected to be | 580 The pattern without explicit kind like ``glob:`` is expected to be |
2160 s = subset | 2209 s = subset |
2161 return baseset([r for r in ls if r in s]) | 2210 return baseset([r for r in ls if r in s]) |
2162 | 2211 |
2163 symbols = { | 2212 symbols = { |
2164 "_mergedefaultdest": _mergedefaultdest, | 2213 "_mergedefaultdest": _mergedefaultdest, |
2214 "_updatedefaultdest": _updatedefaultdest, | |
2165 "adds": adds, | 2215 "adds": adds, |
2166 "all": getall, | 2216 "all": getall, |
2167 "ancestor": ancestor, | 2217 "ancestor": ancestor, |
2168 "ancestors": ancestors, | 2218 "ancestors": ancestors, |
2169 "_firstancestors": _firstancestors, | 2219 "_firstancestors": _firstancestors, |