5 # This software may be used and distributed according to the terms of the |
5 # This software may be used and distributed according to the terms of the |
6 # GNU General Public License version 2 or any later version. |
6 # GNU General Public License version 2 or any later version. |
7 |
7 |
8 from .i18n import _ |
8 from .i18n import _ |
9 from . import ( |
9 from . import ( |
|
10 bookmarks, |
10 error, |
11 error, |
11 obsolete, |
12 obsolete, |
12 ) |
13 ) |
13 |
14 |
14 def destupdate(repo, clean=False, check=False): |
15 def destupdate(repo, clean=False, check=False): |
15 """destination for bare update operation |
16 """destination for bare update operation |
|
17 |
|
18 return (rev, movemark, activemark) |
|
19 |
|
20 - rev: the revision to update to, |
|
21 - movemark: node to move the active bookmark from |
|
22 (cf bookmark.calculate update), |
|
23 - activemark: a bookmark to activate at the end of the update. |
16 """ |
24 """ |
17 # Here is where we should consider bookmarks, divergent bookmarks, and tip |
|
18 # of current branch; but currently we are only checking the branch tips. |
|
19 node = None |
25 node = None |
20 wc = repo[None] |
26 wc = repo[None] |
21 p1 = wc.p1() |
27 p1 = wc.p1() |
22 try: |
28 activemark = None |
23 node = repo.branchtip(wc.branch()) |
29 |
24 except error.RepoLookupError: |
30 # we also move the active bookmark, if any |
25 if wc.branch() == 'default': # no default branch! |
31 node, movemark = bookmarks.calculateupdate(repo.ui, repo, None) |
26 node = repo.lookup('tip') # update to tip |
32 if node is not None: |
27 else: |
33 activemark = node |
28 raise error.Abort(_("branch %s not found") % wc.branch()) |
34 |
|
35 if node is None: |
|
36 try: |
|
37 node = repo.branchtip(wc.branch()) |
|
38 except error.RepoLookupError: |
|
39 if wc.branch() == 'default': # no default branch! |
|
40 node = repo.lookup('tip') # update to tip |
|
41 else: |
|
42 raise error.Abort(_("branch %s not found") % wc.branch()) |
29 |
43 |
30 if p1.obsolete() and not p1.children(): |
44 if p1.obsolete() and not p1.children(): |
31 # allow updating to successors |
45 # allow updating to successors |
32 successors = obsolete.successorssets(repo, p1.node()) |
46 successors = obsolete.successorssets(repo, p1.node()) |
33 |
47 |
74 elif not check: # destination is not a descendant. |
88 elif not check: # destination is not a descendant. |
75 msg = _("not a linear update") |
89 msg = _("not a linear update") |
76 hint = _("merge or update --check to force update") |
90 hint = _("merge or update --check to force update") |
77 raise error.Abort(msg, hint=hint) |
91 raise error.Abort(msg, hint=hint) |
78 |
92 |
79 return rev |
93 return rev, movemark, activemark |