Show More
@@ -20,7 +20,7 b' import merge as mergemod' | |||||
20 | import minirst, revset, fileset |
|
20 | import minirst, revset, fileset | |
21 | import dagparser, context, simplemerge, graphmod, copies |
|
21 | import dagparser, context, simplemerge, graphmod, copies | |
22 | import random, operator |
|
22 | import random, operator | |
23 | import setdiscovery, treediscovery, dagutil, pvec, localrepo |
|
23 | import setdiscovery, treediscovery, dagutil, pvec, localrepo, destutil | |
24 | import phases, obsolete, exchange, bundle2, repair, lock as lockmod |
|
24 | import phases, obsolete, exchange, bundle2, repair, lock as lockmod | |
25 | import ui as uimod |
|
25 | import ui as uimod | |
26 |
|
26 | |||
@@ -6597,6 +6597,8 b' def update(ui, repo, node=None, rev=None' | |||||
6597 | cmdutil.bailifchanged(repo, merge=False) |
|
6597 | cmdutil.bailifchanged(repo, merge=False) | |
6598 | if rev is None: |
|
6598 | if rev is None: | |
6599 | rev = repo[repo[None].branch()].rev() |
|
6599 | rev = repo[repo[None].branch()].rev() | |
|
6600 | elif rev is None: | |||
|
6601 | rev = destutil.destupdate(repo, clean=clean) | |||
6600 |
|
6602 | |||
6601 | repo.ui.setconfig('ui', 'forcemerge', tool, 'update') |
|
6603 | repo.ui.setconfig('ui', 'forcemerge', tool, 'update') | |
6602 |
|
6604 |
@@ -11,7 +11,7 b' from . import (' | |||||
11 | obsolete, |
|
11 | obsolete, | |
12 | ) |
|
12 | ) | |
13 |
|
13 | |||
14 | def destupdate(repo): |
|
14 | def destupdate(repo, clean=False): | |
15 | """destination for bare update operation |
|
15 | """destination for bare update operation | |
16 | """ |
|
16 | """ | |
17 | # Here is where we should consider bookmarks, divergent bookmarks, and tip |
|
17 | # Here is where we should consider bookmarks, divergent bookmarks, and tip | |
@@ -52,4 +52,28 b' def destupdate(repo):' | |||||
52 | # get the max revision for the given successors set, |
|
52 | # get the max revision for the given successors set, | |
53 | # i.e. the 'tip' of a set |
|
53 | # i.e. the 'tip' of a set | |
54 | node = repo.revs('max(%ln)', successors).first() |
|
54 | node = repo.revs('max(%ln)', successors).first() | |
55 |
re |
|
55 | rev = repo[node].rev() | |
|
56 | ||||
|
57 | if not clean: | |||
|
58 | # Check that the update is linear. | |||
|
59 | # | |||
|
60 | # Mercurial do not allow update-merge for non linear pattern | |||
|
61 | # (that would be technically possible but was considered too confusing | |||
|
62 | # for user a long time ago) | |||
|
63 | # | |||
|
64 | # See mercurial.merge.update for details | |||
|
65 | if p1.rev() not in repo.changelog.ancestors([rev], inclusive=True): | |||
|
66 | dirty = wc.dirty(missing=True) | |||
|
67 | foreground = obsolete.foreground(repo, [p1.node()]) | |||
|
68 | if not repo[rev].node() in foreground: | |||
|
69 | if dirty: | |||
|
70 | msg = _("uncommitted changes") | |||
|
71 | hint = _("commit and merge, or update --clean to" | |||
|
72 | " discard changes") | |||
|
73 | raise error.Abort(msg, hint=hint) | |||
|
74 | else: # destination is not a descendant. | |||
|
75 | msg = _("not a linear update") | |||
|
76 | hint = _("merge or update --check to force update") | |||
|
77 | raise error.Abort(msg, hint=hint) | |||
|
78 | ||||
|
79 | return rev |
General Comments 0
You need to be logged in to leave comments.
Login now