Show More
@@ -0,0 +1,56 b'' | |||||
|
1 | # destutil.py - Mercurial utility function for command destination | |||
|
2 | # | |||
|
3 | # Copyright Matt Mackall <mpm@selenic.com> and other | |||
|
4 | # | |||
|
5 | # This software may be used and distributed according to the terms of the | |||
|
6 | # GNU General Public License version 2 or any later version. | |||
|
7 | ||||
|
8 | from .i18n import _ | |||
|
9 | from . import ( | |||
|
10 | error, | |||
|
11 | util, | |||
|
12 | obsolete, | |||
|
13 | ) | |||
|
14 | ||||
|
15 | def destupdate(repo): | |||
|
16 | """destination for bare update operation | |||
|
17 | """ | |||
|
18 | # Here is where we should consider bookmarks, divergent bookmarks, and tip | |||
|
19 | # of current branch; but currently we are only checking the branch tips. | |||
|
20 | node = None | |||
|
21 | wc = repo[None] | |||
|
22 | p1 = wc.p1() | |||
|
23 | try: | |||
|
24 | node = repo.branchtip(wc.branch()) | |||
|
25 | except error.RepoLookupError: | |||
|
26 | if wc.branch() == 'default': # no default branch! | |||
|
27 | node = repo.lookup('tip') # update to tip | |||
|
28 | else: | |||
|
29 | raise util.Abort(_("branch %s not found") % wc.branch()) | |||
|
30 | ||||
|
31 | if p1.obsolete() and not p1.children(): | |||
|
32 | # allow updating to successors | |||
|
33 | successors = obsolete.successorssets(repo, p1.node()) | |||
|
34 | ||||
|
35 | # behavior of certain cases is as follows, | |||
|
36 | # | |||
|
37 | # divergent changesets: update to highest rev, similar to what | |||
|
38 | # is currently done when there are more than one head | |||
|
39 | # (i.e. 'tip') | |||
|
40 | # | |||
|
41 | # replaced changesets: same as divergent except we know there | |||
|
42 | # is no conflict | |||
|
43 | # | |||
|
44 | # pruned changeset: no update is done; though, we could | |||
|
45 | # consider updating to the first non-obsolete parent, | |||
|
46 | # similar to what is current done for 'hg prune' | |||
|
47 | ||||
|
48 | if successors: | |||
|
49 | # flatten the list here handles both divergent (len > 1) | |||
|
50 | # and the usual case (len = 1) | |||
|
51 | successors = [n for sub in successors for n in sub] | |||
|
52 | ||||
|
53 | # get the max revision for the given successors set, | |||
|
54 | # i.e. the 'tip' of a set | |||
|
55 | node = repo.revs('max(%ln)', successors).first() | |||
|
56 | return repo[node].rev() |
@@ -12,6 +12,7 b' import re' | |||||
12 |
|
12 | |||
13 | from .i18n import _ |
|
13 | from .i18n import _ | |
14 | from . import ( |
|
14 | from . import ( | |
|
15 | destutil, | |||
15 | encoding, |
|
16 | encoding, | |
16 | error, |
|
17 | error, | |
17 | hbisect, |
|
18 | hbisect, | |
@@ -532,46 +533,8 b' def _updatedefaultdest(repo, subset, x):' | |||||
532 | # # XXX: - taking rev as arguments, |
|
533 | # # XXX: - taking rev as arguments, | |
533 | # # XXX: - bailing out in case of ambiguity vs returning all data. |
|
534 | # # XXX: - bailing out in case of ambiguity vs returning all data. | |
534 | getargs(x, 0, 0, _("_updatedefaultdest takes no arguments")) |
|
535 | getargs(x, 0, 0, _("_updatedefaultdest takes no arguments")) | |
535 | # Here is where we should consider bookmarks, divergent bookmarks, |
|
536 | rev = destutil.destupdate(repo) | |
536 | # foreground changesets (successors), and tip of current branch; |
|
537 | return subset & baseset([rev]) | |
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 |
|
538 | |||
576 | def adds(repo, subset, x): |
|
539 | def adds(repo, subset, x): | |
577 | """``adds(pattern)`` |
|
540 | """``adds(pattern)`` |
General Comments 0
You need to be logged in to leave comments.
Login now