Mercurial > hg
annotate mercurial/destutil.py @ 52291:b65085c6d6ff
help: modernize the help text for `hostsecurity.minimumprotocol`
Two issues here:
1) We're well past Pythons that only support TLSv1.0 (py27 supports v1.2)
2) It never occurred to me that this is a client-only setting
author | Matt Harbison <matt_harbison@yahoo.com> |
---|---|
date | Mon, 11 Nov 2024 13:03:13 -0500 |
parents | f4733654f144 |
children |
rev | line source |
---|---|
26569
2aeeef1dc9a5
update: move default destination computation to a function
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff
changeset
|
1 # destutil.py - Mercurial utility function for command destination |
2aeeef1dc9a5
update: move default destination computation to a function
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff
changeset
|
2 # |
46819
d4ba4d51f85f
contributor: change mentions of mpm to olivia
Raphaël Gomès <rgomes@octobus.net>
parents:
45843
diff
changeset
|
3 # Copyright Olivia Mackall <olivia@selenic.com> and other |
26569
2aeeef1dc9a5
update: move default destination computation to a function
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff
changeset
|
4 # |
2aeeef1dc9a5
update: move default destination computation to a function
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff
changeset
|
5 # This software may be used and distributed according to the terms of the |
2aeeef1dc9a5
update: move default destination computation to a function
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff
changeset
|
6 # GNU General Public License version 2 or any later version. |
2aeeef1dc9a5
update: move default destination computation to a function
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff
changeset
|
7 |
51863
f4733654f144
typing: add `from __future__ import annotations` to most files
Matt Harbison <matt_harbison@yahoo.com>
parents:
48875
diff
changeset
|
8 from __future__ import annotations |
27333
2c60b4b2a0de
destutil: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27262
diff
changeset
|
9 |
26569
2aeeef1dc9a5
update: move default destination computation to a function
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff
changeset
|
10 from .i18n import _ |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
41146
diff
changeset
|
11 from . import bookmarks, error, obsutil, scmutil, stack |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
41146
diff
changeset
|
12 |
26569
2aeeef1dc9a5
update: move default destination computation to a function
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff
changeset
|
13 |
37787
92213f6745ed
rebase: introduce support for automatically rebasing orphan changes
Augie Fackler <augie@google.com>
parents:
37452
diff
changeset
|
14 def orphanpossibledestination(repo, rev): |
92213f6745ed
rebase: introduce support for automatically rebasing orphan changes
Augie Fackler <augie@google.com>
parents:
37452
diff
changeset
|
15 """Return all changesets that may be a new parent for orphan `rev`. |
92213f6745ed
rebase: introduce support for automatically rebasing orphan changes
Augie Fackler <augie@google.com>
parents:
37452
diff
changeset
|
16 |
92213f6745ed
rebase: introduce support for automatically rebasing orphan changes
Augie Fackler <augie@google.com>
parents:
37452
diff
changeset
|
17 This function works fine on non-orphan revisions, it's just silly |
92213f6745ed
rebase: introduce support for automatically rebasing orphan changes
Augie Fackler <augie@google.com>
parents:
37452
diff
changeset
|
18 because there's no destination implied by obsolete markers, so |
92213f6745ed
rebase: introduce support for automatically rebasing orphan changes
Augie Fackler <augie@google.com>
parents:
37452
diff
changeset
|
19 it'll return nothing. |
92213f6745ed
rebase: introduce support for automatically rebasing orphan changes
Augie Fackler <augie@google.com>
parents:
37452
diff
changeset
|
20 """ |
92213f6745ed
rebase: introduce support for automatically rebasing orphan changes
Augie Fackler <augie@google.com>
parents:
37452
diff
changeset
|
21 tonode = repo.changelog.node |
92213f6745ed
rebase: introduce support for automatically rebasing orphan changes
Augie Fackler <augie@google.com>
parents:
37452
diff
changeset
|
22 parents = repo.changelog.parentrevs |
92213f6745ed
rebase: introduce support for automatically rebasing orphan changes
Augie Fackler <augie@google.com>
parents:
37452
diff
changeset
|
23 torev = repo.changelog.rev |
92213f6745ed
rebase: introduce support for automatically rebasing orphan changes
Augie Fackler <augie@google.com>
parents:
37452
diff
changeset
|
24 dest = set() |
92213f6745ed
rebase: introduce support for automatically rebasing orphan changes
Augie Fackler <augie@google.com>
parents:
37452
diff
changeset
|
25 tovisit = list(parents(rev)) |
92213f6745ed
rebase: introduce support for automatically rebasing orphan changes
Augie Fackler <augie@google.com>
parents:
37452
diff
changeset
|
26 while tovisit: |
92213f6745ed
rebase: introduce support for automatically rebasing orphan changes
Augie Fackler <augie@google.com>
parents:
37452
diff
changeset
|
27 r = tovisit.pop() |
92213f6745ed
rebase: introduce support for automatically rebasing orphan changes
Augie Fackler <augie@google.com>
parents:
37452
diff
changeset
|
28 succsets = obsutil.successorssets(repo, tonode(r)) |
92213f6745ed
rebase: introduce support for automatically rebasing orphan changes
Augie Fackler <augie@google.com>
parents:
37452
diff
changeset
|
29 if not succsets: |
92213f6745ed
rebase: introduce support for automatically rebasing orphan changes
Augie Fackler <augie@google.com>
parents:
37452
diff
changeset
|
30 # if there are no successors for r, r was probably pruned |
92213f6745ed
rebase: introduce support for automatically rebasing orphan changes
Augie Fackler <augie@google.com>
parents:
37452
diff
changeset
|
31 # and we should walk up to r's parents to try and find |
92213f6745ed
rebase: introduce support for automatically rebasing orphan changes
Augie Fackler <augie@google.com>
parents:
37452
diff
changeset
|
32 # some successors. |
92213f6745ed
rebase: introduce support for automatically rebasing orphan changes
Augie Fackler <augie@google.com>
parents:
37452
diff
changeset
|
33 tovisit.extend(parents(r)) |
92213f6745ed
rebase: introduce support for automatically rebasing orphan changes
Augie Fackler <augie@google.com>
parents:
37452
diff
changeset
|
34 else: |
92213f6745ed
rebase: introduce support for automatically rebasing orphan changes
Augie Fackler <augie@google.com>
parents:
37452
diff
changeset
|
35 # We should probably pick only one destination from split |
92213f6745ed
rebase: introduce support for automatically rebasing orphan changes
Augie Fackler <augie@google.com>
parents:
37452
diff
changeset
|
36 # (case where '1 < len(ss)'), This could be the currently |
92213f6745ed
rebase: introduce support for automatically rebasing orphan changes
Augie Fackler <augie@google.com>
parents:
37452
diff
changeset
|
37 # tipmost, but the correct result is less clear when |
92213f6745ed
rebase: introduce support for automatically rebasing orphan changes
Augie Fackler <augie@google.com>
parents:
37452
diff
changeset
|
38 # results of the split have been moved such that they |
92213f6745ed
rebase: introduce support for automatically rebasing orphan changes
Augie Fackler <augie@google.com>
parents:
37452
diff
changeset
|
39 # reside on multiple branches. |
92213f6745ed
rebase: introduce support for automatically rebasing orphan changes
Augie Fackler <augie@google.com>
parents:
37452
diff
changeset
|
40 for ss in succsets: |
92213f6745ed
rebase: introduce support for automatically rebasing orphan changes
Augie Fackler <augie@google.com>
parents:
37452
diff
changeset
|
41 for n in ss: |
92213f6745ed
rebase: introduce support for automatically rebasing orphan changes
Augie Fackler <augie@google.com>
parents:
37452
diff
changeset
|
42 dr = torev(n) |
92213f6745ed
rebase: introduce support for automatically rebasing orphan changes
Augie Fackler <augie@google.com>
parents:
37452
diff
changeset
|
43 if dr != -1: |
92213f6745ed
rebase: introduce support for automatically rebasing orphan changes
Augie Fackler <augie@google.com>
parents:
37452
diff
changeset
|
44 dest.add(dr) |
92213f6745ed
rebase: introduce support for automatically rebasing orphan changes
Augie Fackler <augie@google.com>
parents:
37452
diff
changeset
|
45 return dest |
92213f6745ed
rebase: introduce support for automatically rebasing orphan changes
Augie Fackler <augie@google.com>
parents:
37452
diff
changeset
|
46 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
41146
diff
changeset
|
47 |
30962
11c253997b0e
destutil: drop now-unused "check" parameter from destupdate()
Martin von Zweigbergk <martinvonz@google.com>
parents:
30961
diff
changeset
|
48 def _destupdateobs(repo, clean): |
26723
52d08a93de1f
destupdate: extract logic based on obsolescence marker in its own function
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
26722
diff
changeset
|
49 """decide of an update destination from obsolescence markers""" |
26569
2aeeef1dc9a5
update: move default destination computation to a function
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff
changeset
|
50 node = None |
2aeeef1dc9a5
update: move default destination computation to a function
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff
changeset
|
51 wc = repo[None] |
2aeeef1dc9a5
update: move default destination computation to a function
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff
changeset
|
52 p1 = wc.p1() |
26723
52d08a93de1f
destupdate: extract logic based on obsolescence marker in its own function
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
26722
diff
changeset
|
53 movemark = None |
26569
2aeeef1dc9a5
update: move default destination computation to a function
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff
changeset
|
54 |
2aeeef1dc9a5
update: move default destination computation to a function
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff
changeset
|
55 if p1.obsolete() and not p1.children(): |
2aeeef1dc9a5
update: move default destination computation to a function
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff
changeset
|
56 # allow updating to successors |
33142
4f49810a1011
obsutil: move 'successorssets' to the new modules
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
32698
diff
changeset
|
57 successors = obsutil.successorssets(repo, p1.node()) |
26569
2aeeef1dc9a5
update: move default destination computation to a function
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff
changeset
|
58 |
2aeeef1dc9a5
update: move default destination computation to a function
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff
changeset
|
59 # behavior of certain cases is as follows, |
2aeeef1dc9a5
update: move default destination computation to a function
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff
changeset
|
60 # |
2aeeef1dc9a5
update: move default destination computation to a function
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff
changeset
|
61 # divergent changesets: update to highest rev, similar to what |
2aeeef1dc9a5
update: move default destination computation to a function
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff
changeset
|
62 # is currently done when there are more than one head |
2aeeef1dc9a5
update: move default destination computation to a function
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff
changeset
|
63 # (i.e. 'tip') |
2aeeef1dc9a5
update: move default destination computation to a function
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff
changeset
|
64 # |
2aeeef1dc9a5
update: move default destination computation to a function
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff
changeset
|
65 # replaced changesets: same as divergent except we know there |
2aeeef1dc9a5
update: move default destination computation to a function
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff
changeset
|
66 # is no conflict |
2aeeef1dc9a5
update: move default destination computation to a function
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff
changeset
|
67 # |
48689
fbf7e383e961
destutil: if wdp is obsolete, update to the closest non-obsolete ancestor
Anton Shestakov <av6@dwimlabs.net>
parents:
48687
diff
changeset
|
68 # pruned changeset: update to the closest non-obsolete ancestor, |
fbf7e383e961
destutil: if wdp is obsolete, update to the closest non-obsolete ancestor
Anton Shestakov <av6@dwimlabs.net>
parents:
48687
diff
changeset
|
69 # similar to what 'hg prune' currently does |
26569
2aeeef1dc9a5
update: move default destination computation to a function
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff
changeset
|
70 |
2aeeef1dc9a5
update: move default destination computation to a function
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff
changeset
|
71 if successors: |
2aeeef1dc9a5
update: move default destination computation to a function
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff
changeset
|
72 # flatten the list here handles both divergent (len > 1) |
2aeeef1dc9a5
update: move default destination computation to a function
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff
changeset
|
73 # and the usual case (len = 1) |
2aeeef1dc9a5
update: move default destination computation to a function
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff
changeset
|
74 successors = [n for sub in successors for n in sub] |
2aeeef1dc9a5
update: move default destination computation to a function
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff
changeset
|
75 |
2aeeef1dc9a5
update: move default destination computation to a function
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff
changeset
|
76 # get the max revision for the given successors set, |
2aeeef1dc9a5
update: move default destination computation to a function
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff
changeset
|
77 # i.e. the 'tip' of a set |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
78 node = repo.revs(b'max(%ln)', successors).first() |
48687
f8f2ecdde4b5
branchmap: skip obsolete revisions while computing heads
Anton Shestakov <av6@dwimlabs.net>
parents:
46819
diff
changeset
|
79 else: |
48689
fbf7e383e961
destutil: if wdp is obsolete, update to the closest non-obsolete ancestor
Anton Shestakov <av6@dwimlabs.net>
parents:
48687
diff
changeset
|
80 p1 = p1.p1() |
fbf7e383e961
destutil: if wdp is obsolete, update to the closest non-obsolete ancestor
Anton Shestakov <av6@dwimlabs.net>
parents:
48687
diff
changeset
|
81 while p1.obsolete(): |
fbf7e383e961
destutil: if wdp is obsolete, update to the closest non-obsolete ancestor
Anton Shestakov <av6@dwimlabs.net>
parents:
48687
diff
changeset
|
82 p1 = p1.p1() |
fbf7e383e961
destutil: if wdp is obsolete, update to the closest non-obsolete ancestor
Anton Shestakov <av6@dwimlabs.net>
parents:
48687
diff
changeset
|
83 node = p1.node() |
fbf7e383e961
destutil: if wdp is obsolete, update to the closest non-obsolete ancestor
Anton Shestakov <av6@dwimlabs.net>
parents:
48687
diff
changeset
|
84 |
fbf7e383e961
destutil: if wdp is obsolete, update to the closest non-obsolete ancestor
Anton Shestakov <av6@dwimlabs.net>
parents:
48687
diff
changeset
|
85 if node is not None and bookmarks.isactivewdirparent(repo): |
fbf7e383e961
destutil: if wdp is obsolete, update to the closest non-obsolete ancestor
Anton Shestakov <av6@dwimlabs.net>
parents:
48687
diff
changeset
|
86 movemark = repo[b'.'].node() |
fbf7e383e961
destutil: if wdp is obsolete, update to the closest non-obsolete ancestor
Anton Shestakov <av6@dwimlabs.net>
parents:
48687
diff
changeset
|
87 |
26723
52d08a93de1f
destupdate: extract logic based on obsolescence marker in its own function
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
26722
diff
changeset
|
88 return node, movemark, None |
52d08a93de1f
destupdate: extract logic based on obsolescence marker in its own function
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
26722
diff
changeset
|
89 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
41146
diff
changeset
|
90 |
30962
11c253997b0e
destutil: drop now-unused "check" parameter from destupdate()
Martin von Zweigbergk <martinvonz@google.com>
parents:
30961
diff
changeset
|
91 def _destupdatebook(repo, clean): |
26724
7fc759c0c430
destupdate: extract logic based on bookmarks in its own function
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
26723
diff
changeset
|
92 """decide on an update destination from active bookmark""" |
7fc759c0c430
destupdate: extract logic based on bookmarks in its own function
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
26723
diff
changeset
|
93 # we also move the active bookmark, if any |
37359
e27298bf11dd
bookmarks: calculateupdate() returns a bookmark, not a rev
Martin von Zweigbergk <martinvonz@google.com>
parents:
37004
diff
changeset
|
94 node = None |
37375
a973bb92ab71
bookmarks: drop always-None argument from calculateupdate()
Martin von Zweigbergk <martinvonz@google.com>
parents:
37359
diff
changeset
|
95 activemark, movemark = bookmarks.calculateupdate(repo.ui, repo) |
37359
e27298bf11dd
bookmarks: calculateupdate() returns a bookmark, not a rev
Martin von Zweigbergk <martinvonz@google.com>
parents:
37004
diff
changeset
|
96 if activemark is not None: |
37452
2b38c80557a4
destutil: look up bookmarks only among bookmarks
Martin von Zweigbergk <martinvonz@google.com>
parents:
37390
diff
changeset
|
97 node = repo._bookmarks[activemark] |
26724
7fc759c0c430
destupdate: extract logic based on bookmarks in its own function
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
26723
diff
changeset
|
98 return node, movemark, activemark |
7fc759c0c430
destupdate: extract logic based on bookmarks in its own function
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
26723
diff
changeset
|
99 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
41146
diff
changeset
|
100 |
30962
11c253997b0e
destutil: drop now-unused "check" parameter from destupdate()
Martin von Zweigbergk <martinvonz@google.com>
parents:
30961
diff
changeset
|
101 def _destupdatebranch(repo, clean): |
28385
3f9e25a42e69
destutil: choose non-closed branch head at first (BC)
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
28266
diff
changeset
|
102 """decide on an update destination from current branch |
3f9e25a42e69
destutil: choose non-closed branch head at first (BC)
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
28266
diff
changeset
|
103 |
3f9e25a42e69
destutil: choose non-closed branch head at first (BC)
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
28266
diff
changeset
|
104 This ignores closed branch heads. |
3f9e25a42e69
destutil: choose non-closed branch head at first (BC)
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
28266
diff
changeset
|
105 """ |
26725
bde739aced83
destupdate: extract logic based on branch in its own function
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
26724
diff
changeset
|
106 wc = repo[None] |
bde739aced83
destupdate: extract logic based on branch in its own function
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
26724
diff
changeset
|
107 movemark = node = None |
28235
c2f0a47069ef
destutil: replace wc.branch() invocations by cached value for efficiency
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
28234
diff
changeset
|
108 currentbranch = wc.branch() |
29284
1c7167009936
update: fix bare --clean to work on new branch (issue5003) (BC)
liscju <piotr.listkiewicz@gmail.com>
parents:
29043
diff
changeset
|
109 |
1c7167009936
update: fix bare --clean to work on new branch (issue5003) (BC)
liscju <piotr.listkiewicz@gmail.com>
parents:
29043
diff
changeset
|
110 if clean: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
111 currentbranch = repo[b'.'].branch() |
29284
1c7167009936
update: fix bare --clean to work on new branch (issue5003) (BC)
liscju <piotr.listkiewicz@gmail.com>
parents:
29043
diff
changeset
|
112 |
28236
e333cea74741
destutil: use cached branch information instead of query for efficiency
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
28235
diff
changeset
|
113 if currentbranch in repo.branchmap(): |
28385
3f9e25a42e69
destutil: choose non-closed branch head at first (BC)
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
28266
diff
changeset
|
114 heads = repo.branchheads(currentbranch) |
28236
e333cea74741
destutil: use cached branch information instead of query for efficiency
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
28235
diff
changeset
|
115 if heads: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
116 node = repo.revs(b'max(.::(%ln))', heads).first() |
26725
bde739aced83
destupdate: extract logic based on branch in its own function
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
26724
diff
changeset
|
117 if bookmarks.isactivewdirparent(repo): |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
118 movemark = repo[b'.'].node() |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
119 elif currentbranch == b'default' and not wc.p1(): |
28924
d9539959167d
update: resurrect bare update from null parent to tip-most branch head
Yuya Nishihara <yuya@tcha.org>
parents:
28903
diff
changeset
|
120 # "null" parent belongs to "default" branch, but it doesn't exist, so |
d9539959167d
update: resurrect bare update from null parent to tip-most branch head
Yuya Nishihara <yuya@tcha.org>
parents:
28903
diff
changeset
|
121 # update to the tipmost non-closed branch head |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
122 node = repo.revs(b'max(head() and not closed())').first() |
28236
e333cea74741
destutil: use cached branch information instead of query for efficiency
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
28235
diff
changeset
|
123 else: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
124 node = repo[b'.'].node() |
26725
bde739aced83
destupdate: extract logic based on branch in its own function
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
26724
diff
changeset
|
125 return node, movemark, None |
bde739aced83
destupdate: extract logic based on branch in its own function
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
26724
diff
changeset
|
126 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
41146
diff
changeset
|
127 |
30962
11c253997b0e
destutil: drop now-unused "check" parameter from destupdate()
Martin von Zweigbergk <martinvonz@google.com>
parents:
30961
diff
changeset
|
128 def _destupdatebranchfallback(repo, clean): |
28385
3f9e25a42e69
destutil: choose non-closed branch head at first (BC)
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
28266
diff
changeset
|
129 """decide on an update destination from closed heads in current branch""" |
3f9e25a42e69
destutil: choose non-closed branch head at first (BC)
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
28266
diff
changeset
|
130 wc = repo[None] |
3f9e25a42e69
destutil: choose non-closed branch head at first (BC)
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
28266
diff
changeset
|
131 currentbranch = wc.branch() |
3f9e25a42e69
destutil: choose non-closed branch head at first (BC)
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
28266
diff
changeset
|
132 movemark = None |
3f9e25a42e69
destutil: choose non-closed branch head at first (BC)
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
28266
diff
changeset
|
133 if currentbranch in repo.branchmap(): |
3f9e25a42e69
destutil: choose non-closed branch head at first (BC)
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
28266
diff
changeset
|
134 # here, all descendant branch heads are closed |
3f9e25a42e69
destutil: choose non-closed branch head at first (BC)
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
28266
diff
changeset
|
135 heads = repo.branchheads(currentbranch, closed=True) |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
136 assert heads, b"any branch has at least one head" |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
137 node = repo.revs(b'max(.::(%ln))', heads).first() |
43117
8ff1ecfadcd1
cleanup: join string literals that are already on one line
Martin von Zweigbergk <martinvonz@google.com>
parents:
43114
diff
changeset
|
138 assert ( |
8ff1ecfadcd1
cleanup: join string literals that are already on one line
Martin von Zweigbergk <martinvonz@google.com>
parents:
43114
diff
changeset
|
139 node is not None |
8ff1ecfadcd1
cleanup: join string literals that are already on one line
Martin von Zweigbergk <martinvonz@google.com>
parents:
43114
diff
changeset
|
140 ), b"any revision has at least one descendant branch head" |
28385
3f9e25a42e69
destutil: choose non-closed branch head at first (BC)
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
28266
diff
changeset
|
141 if bookmarks.isactivewdirparent(repo): |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
142 movemark = repo[b'.'].node() |
28385
3f9e25a42e69
destutil: choose non-closed branch head at first (BC)
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
28266
diff
changeset
|
143 else: |
3f9e25a42e69
destutil: choose non-closed branch head at first (BC)
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
28266
diff
changeset
|
144 # here, no "default" branch, and all branches are closed |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
145 node = repo.lookup(b'tip') |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
146 assert node is not None, b"'tip' exists even in empty repository" |
28385
3f9e25a42e69
destutil: choose non-closed branch head at first (BC)
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
28266
diff
changeset
|
147 return node, movemark, None |
3f9e25a42e69
destutil: choose non-closed branch head at first (BC)
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
28266
diff
changeset
|
148 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
41146
diff
changeset
|
149 |
30332
318a24b52eeb
spelling: fixes of non-dictionary words
Mads Kiilerich <madski@unity3d.com>
parents:
29964
diff
changeset
|
150 # order in which each step should be evaluated |
26726
8e6649616699
destupdate: have a generic and extensible way to run each step
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
26725
diff
changeset
|
151 # steps are run until one finds a destination |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
152 destupdatesteps = [b'evolution', b'bookmark', b'branch', b'branchfallback'] |
26726
8e6649616699
destupdate: have a generic and extensible way to run each step
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
26725
diff
changeset
|
153 # mapping to ease extension overriding steps. |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
41146
diff
changeset
|
154 destupdatestepmap = { |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
155 b'evolution': _destupdateobs, |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
156 b'bookmark': _destupdatebook, |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
157 b'branch': _destupdatebranch, |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
158 b'branchfallback': _destupdatebranchfallback, |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
41146
diff
changeset
|
159 } |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
41146
diff
changeset
|
160 |
26726
8e6649616699
destupdate: have a generic and extensible way to run each step
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
26725
diff
changeset
|
161 |
30962
11c253997b0e
destutil: drop now-unused "check" parameter from destupdate()
Martin von Zweigbergk <martinvonz@google.com>
parents:
30961
diff
changeset
|
162 def destupdate(repo, clean=False): |
26723
52d08a93de1f
destupdate: extract logic based on obsolescence marker in its own function
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
26722
diff
changeset
|
163 """destination for bare update operation |
52d08a93de1f
destupdate: extract logic based on obsolescence marker in its own function
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
26722
diff
changeset
|
164 |
52d08a93de1f
destupdate: extract logic based on obsolescence marker in its own function
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
26722
diff
changeset
|
165 return (rev, movemark, activemark) |
52d08a93de1f
destupdate: extract logic based on obsolescence marker in its own function
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
26722
diff
changeset
|
166 |
52d08a93de1f
destupdate: extract logic based on obsolescence marker in its own function
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
26722
diff
changeset
|
167 - rev: the revision to update to, |
52d08a93de1f
destupdate: extract logic based on obsolescence marker in its own function
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
26722
diff
changeset
|
168 - movemark: node to move the active bookmark from |
52d08a93de1f
destupdate: extract logic based on obsolescence marker in its own function
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
26722
diff
changeset
|
169 (cf bookmark.calculate update), |
52d08a93de1f
destupdate: extract logic based on obsolescence marker in its own function
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
26722
diff
changeset
|
170 - activemark: a bookmark to activate at the end of the update. |
52d08a93de1f
destupdate: extract logic based on obsolescence marker in its own function
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
26722
diff
changeset
|
171 """ |
26726
8e6649616699
destupdate: have a generic and extensible way to run each step
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
26725
diff
changeset
|
172 node = movemark = activemark = None |
26723
52d08a93de1f
destupdate: extract logic based on obsolescence marker in its own function
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
26722
diff
changeset
|
173 |
26726
8e6649616699
destupdate: have a generic and extensible way to run each step
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
26725
diff
changeset
|
174 for step in destupdatesteps: |
30962
11c253997b0e
destutil: drop now-unused "check" parameter from destupdate()
Martin von Zweigbergk <martinvonz@google.com>
parents:
30961
diff
changeset
|
175 node, movemark, activemark = destupdatestepmap[step](repo, clean) |
26726
8e6649616699
destupdate: have a generic and extensible way to run each step
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
26725
diff
changeset
|
176 if node is not None: |
8e6649616699
destupdate: have a generic and extensible way to run each step
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
26725
diff
changeset
|
177 break |
26628
45b86dbabbda
destupdate: move the check related to the "clean" logic in the function
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
26587
diff
changeset
|
178 rev = repo[node].rev() |
45b86dbabbda
destupdate: move the check related to the "clean" logic in the function
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
26587
diff
changeset
|
179 |
26641
5c57d01fe64e
destupdate: also include bookmark related logic
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
26629
diff
changeset
|
180 return rev, movemark, activemark |
26714
9903261dcc81
destutil: move default merge destination into a function
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
26683
diff
changeset
|
181 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
41146
diff
changeset
|
182 |
28102
bd74b5e0d2c0
destutil: extract all 'mergedest' abort messages into a dictionary
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
28065
diff
changeset
|
183 msgdestmerge = { |
bd74b5e0d2c0
destutil: extract all 'mergedest' abort messages into a dictionary
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
28065
diff
changeset
|
184 # too many matching divergent bookmark |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
185 b'toomanybookmarks': { |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
186 b'merge': ( |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
41146
diff
changeset
|
187 _( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
188 b"multiple matching bookmarks to merge -" |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
189 b" please merge with an explicit rev or bookmark" |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
41146
diff
changeset
|
190 ), |
43114
8197b395710e
destutil: provide hint on rebase+merge for how to specify destination/rev
Kyle Lippincott <spectral@google.com>
parents:
43077
diff
changeset
|
191 _(b"run 'hg heads' to see all heads, specify rev with -r"), |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
41146
diff
changeset
|
192 ), |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
193 b'rebase': ( |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
41146
diff
changeset
|
194 _( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
195 b"multiple matching bookmarks to rebase -" |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
196 b" please rebase to an explicit rev or bookmark" |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
41146
diff
changeset
|
197 ), |
43114
8197b395710e
destutil: provide hint on rebase+merge for how to specify destination/rev
Kyle Lippincott <spectral@google.com>
parents:
43077
diff
changeset
|
198 _(b"run 'hg heads' to see all heads, specify destination with -d"), |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
41146
diff
changeset
|
199 ), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
41146
diff
changeset
|
200 }, |
28102
bd74b5e0d2c0
destutil: extract all 'mergedest' abort messages into a dictionary
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
28065
diff
changeset
|
201 # no other matching divergent bookmark |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
202 b'nootherbookmarks': { |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
203 b'merge': ( |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
41146
diff
changeset
|
204 _( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
205 b"no matching bookmark to merge - " |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
206 b"please merge with an explicit rev or bookmark" |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
41146
diff
changeset
|
207 ), |
43114
8197b395710e
destutil: provide hint on rebase+merge for how to specify destination/rev
Kyle Lippincott <spectral@google.com>
parents:
43077
diff
changeset
|
208 _(b"run 'hg heads' to see all heads, specify rev with -r"), |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
41146
diff
changeset
|
209 ), |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
210 b'rebase': ( |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
41146
diff
changeset
|
211 _( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
212 b"no matching bookmark to rebase - " |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
213 b"please rebase to an explicit rev or bookmark" |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
41146
diff
changeset
|
214 ), |
43114
8197b395710e
destutil: provide hint on rebase+merge for how to specify destination/rev
Kyle Lippincott <spectral@google.com>
parents:
43077
diff
changeset
|
215 _(b"run 'hg heads' to see all heads, specify destination with -d"), |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
41146
diff
changeset
|
216 ), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
41146
diff
changeset
|
217 }, |
28102
bd74b5e0d2c0
destutil: extract all 'mergedest' abort messages into a dictionary
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
28065
diff
changeset
|
218 # branch have too many unbookmarked heads, no obvious destination |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
219 b'toomanyheads': { |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
220 b'merge': ( |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
221 _(b"branch '%s' has %d heads - please merge with an explicit rev"), |
43114
8197b395710e
destutil: provide hint on rebase+merge for how to specify destination/rev
Kyle Lippincott <spectral@google.com>
parents:
43077
diff
changeset
|
222 _(b"run 'hg heads .' to see heads, specify rev with -r"), |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
41146
diff
changeset
|
223 ), |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
224 b'rebase': ( |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
225 _(b"branch '%s' has %d heads - please rebase to an explicit rev"), |
43114
8197b395710e
destutil: provide hint on rebase+merge for how to specify destination/rev
Kyle Lippincott <spectral@google.com>
parents:
43077
diff
changeset
|
226 _(b"run 'hg heads .' to see heads, specify destination with -d"), |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
41146
diff
changeset
|
227 ), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
41146
diff
changeset
|
228 }, |
28102
bd74b5e0d2c0
destutil: extract all 'mergedest' abort messages into a dictionary
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
28065
diff
changeset
|
229 # branch have no other unbookmarked heads |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
230 b'bookmarkedheads': { |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
231 b'merge': ( |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
232 _(b"heads are bookmarked - please merge with an explicit rev"), |
43114
8197b395710e
destutil: provide hint on rebase+merge for how to specify destination/rev
Kyle Lippincott <spectral@google.com>
parents:
43077
diff
changeset
|
233 _(b"run 'hg heads' to see all heads, specify rev with -r"), |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
41146
diff
changeset
|
234 ), |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
235 b'rebase': ( |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
236 _(b"heads are bookmarked - please rebase to an explicit rev"), |
43114
8197b395710e
destutil: provide hint on rebase+merge for how to specify destination/rev
Kyle Lippincott <spectral@google.com>
parents:
43077
diff
changeset
|
237 _(b"run 'hg heads' to see all heads, specify destination with -d"), |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
41146
diff
changeset
|
238 ), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
41146
diff
changeset
|
239 }, |
28102
bd74b5e0d2c0
destutil: extract all 'mergedest' abort messages into a dictionary
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
28065
diff
changeset
|
240 # branch have just a single heads, but there is other branches |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
241 b'nootherbranchheads': { |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
242 b'merge': ( |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
243 _(b"branch '%s' has one head - please merge with an explicit rev"), |
43114
8197b395710e
destutil: provide hint on rebase+merge for how to specify destination/rev
Kyle Lippincott <spectral@google.com>
parents:
43077
diff
changeset
|
244 _(b"run 'hg heads' to see all heads, specify rev with -r"), |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
41146
diff
changeset
|
245 ), |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
246 b'rebase': ( |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
247 _(b"branch '%s' has one head - please rebase to an explicit rev"), |
43114
8197b395710e
destutil: provide hint on rebase+merge for how to specify destination/rev
Kyle Lippincott <spectral@google.com>
parents:
43077
diff
changeset
|
248 _(b"run 'hg heads' to see all heads, specify destination with -d"), |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
41146
diff
changeset
|
249 ), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
41146
diff
changeset
|
250 }, |
28102
bd74b5e0d2c0
destutil: extract all 'mergedest' abort messages into a dictionary
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
28065
diff
changeset
|
251 # repository have a single head |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
252 b'nootherheads': { |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
253 b'merge': (_(b'nothing to merge'), None), |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
254 b'rebase': (_(b'nothing to rebase'), None), |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
41146
diff
changeset
|
255 }, |
28102
bd74b5e0d2c0
destutil: extract all 'mergedest' abort messages into a dictionary
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
28065
diff
changeset
|
256 # repository have a single head and we are not on it |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
257 b'nootherheadsbehind': { |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
258 b'merge': (_(b'nothing to merge'), _(b"use 'hg update' instead")), |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
259 b'rebase': (_(b'nothing to rebase'), _(b"use 'hg update' instead")), |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
41146
diff
changeset
|
260 }, |
28102
bd74b5e0d2c0
destutil: extract all 'mergedest' abort messages into a dictionary
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
28065
diff
changeset
|
261 # We are not on a head |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
262 b'notatheads': { |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
263 b'merge': ( |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
264 _(b'working directory not at a head revision'), |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
265 _(b"use 'hg update' or merge with an explicit revision"), |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
41146
diff
changeset
|
266 ), |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
267 b'rebase': ( |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
268 _(b'working directory not at a head revision'), |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
269 _(b"use 'hg update' or rebase to an explicit revision"), |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
41146
diff
changeset
|
270 ), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
41146
diff
changeset
|
271 }, |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
272 b'emptysourceset': { |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
273 b'merge': (_(b'source set is empty'), None), |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
274 b'rebase': (_(b'source set is empty'), None), |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
41146
diff
changeset
|
275 }, |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
276 b'multiplebranchessourceset': { |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
277 b'merge': (_(b'source set is rooted in multiple branches'), None), |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
278 b'rebase': ( |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
279 _(b'rebaseset is rooted in multiple named branches'), |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
280 _(b'specify an explicit destination with --dest'), |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
41146
diff
changeset
|
281 ), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
41146
diff
changeset
|
282 }, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
41146
diff
changeset
|
283 } |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
41146
diff
changeset
|
284 |
28102
bd74b5e0d2c0
destutil: extract all 'mergedest' abort messages into a dictionary
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
28065
diff
changeset
|
285 |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
286 def _destmergebook(repo, action=b'merge', sourceset=None, destspace=None): |
26727
5b7fd48f9868
destmerge: extract logic based on bookmark into its own function
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
26726
diff
changeset
|
287 """find merge destination in the active bookmark case""" |
5b7fd48f9868
destmerge: extract logic based on bookmark into its own function
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
26726
diff
changeset
|
288 node = None |
32381
b9942bc6b292
localrepo: extract bookmarkheads method to bookmarks.py
Augie Fackler <augie@google.com>
parents:
31025
diff
changeset
|
289 bmheads = bookmarks.headsforactive(repo) |
37452
2b38c80557a4
destutil: look up bookmarks only among bookmarks
Martin von Zweigbergk <martinvonz@google.com>
parents:
37390
diff
changeset
|
290 curhead = repo._bookmarks[repo._activebookmark] |
26727
5b7fd48f9868
destmerge: extract logic based on bookmark into its own function
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
26726
diff
changeset
|
291 if len(bmheads) == 2: |
5b7fd48f9868
destmerge: extract logic based on bookmark into its own function
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
26726
diff
changeset
|
292 if curhead == bmheads[0]: |
5b7fd48f9868
destmerge: extract logic based on bookmark into its own function
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
26726
diff
changeset
|
293 node = bmheads[1] |
5b7fd48f9868
destmerge: extract logic based on bookmark into its own function
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
26726
diff
changeset
|
294 else: |
5b7fd48f9868
destmerge: extract logic based on bookmark into its own function
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
26726
diff
changeset
|
295 node = bmheads[0] |
5b7fd48f9868
destmerge: extract logic based on bookmark into its own function
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
26726
diff
changeset
|
296 elif len(bmheads) > 2: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
297 msg, hint = msgdestmerge[b'toomanybookmarks'][action] |
28141
13bb8de97f87
destutil: add more precise error classes for destmerge
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
28140
diff
changeset
|
298 raise error.ManyMergeDestAbort(msg, hint=hint) |
26727
5b7fd48f9868
destmerge: extract logic based on bookmark into its own function
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
26726
diff
changeset
|
299 elif len(bmheads) <= 1: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
300 msg, hint = msgdestmerge[b'nootherbookmarks'][action] |
28141
13bb8de97f87
destutil: add more precise error classes for destmerge
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
28140
diff
changeset
|
301 raise error.NoMergeDestAbort(msg, hint=hint) |
26727
5b7fd48f9868
destmerge: extract logic based on bookmark into its own function
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
26726
diff
changeset
|
302 assert node is not None |
5b7fd48f9868
destmerge: extract logic based on bookmark into its own function
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
26726
diff
changeset
|
303 return node |
5b7fd48f9868
destmerge: extract logic based on bookmark into its own function
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
26726
diff
changeset
|
304 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
41146
diff
changeset
|
305 |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
41146
diff
changeset
|
306 def _destmergebranch( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
307 repo, action=b'merge', sourceset=None, onheadcheck=True, destspace=None |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
41146
diff
changeset
|
308 ): |
26728
e8f1b7285917
destmerge: extract logic based on branch heads in its own function
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
26727
diff
changeset
|
309 """find merge destination based on branch heads""" |
e8f1b7285917
destmerge: extract logic based on branch heads in its own function
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
26727
diff
changeset
|
310 node = None |
28139
5476a7a039c0
destutil: allow to specify an explicit source for the merge
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
28138
diff
changeset
|
311 |
5476a7a039c0
destutil: allow to specify an explicit source for the merge
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
28138
diff
changeset
|
312 if sourceset is None: |
5476a7a039c0
destutil: allow to specify an explicit source for the merge
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
28138
diff
changeset
|
313 sourceset = [repo[repo.dirstate.p1()].rev()] |
5476a7a039c0
destutil: allow to specify an explicit source for the merge
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
28138
diff
changeset
|
314 branch = repo.dirstate.branch() |
5476a7a039c0
destutil: allow to specify an explicit source for the merge
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
28138
diff
changeset
|
315 elif not sourceset: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
316 msg, hint = msgdestmerge[b'emptysourceset'][action] |
28141
13bb8de97f87
destutil: add more precise error classes for destmerge
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
28140
diff
changeset
|
317 raise error.NoMergeDestAbort(msg, hint=hint) |
28139
5476a7a039c0
destutil: allow to specify an explicit source for the merge
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
28138
diff
changeset
|
318 else: |
5476a7a039c0
destutil: allow to specify an explicit source for the merge
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
28138
diff
changeset
|
319 branch = None |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
320 for ctx in repo.set(b'roots(%ld::%ld)', sourceset, sourceset): |
28139
5476a7a039c0
destutil: allow to specify an explicit source for the merge
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
28138
diff
changeset
|
321 if branch is not None and ctx.branch() != branch: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
322 msg, hint = msgdestmerge[b'multiplebranchessourceset'][action] |
28141
13bb8de97f87
destutil: add more precise error classes for destmerge
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
28140
diff
changeset
|
323 raise error.ManyMergeDestAbort(msg, hint=hint) |
28139
5476a7a039c0
destutil: allow to specify an explicit source for the merge
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
28138
diff
changeset
|
324 branch = ctx.branch() |
5476a7a039c0
destutil: allow to specify an explicit source for the merge
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
28138
diff
changeset
|
325 |
26728
e8f1b7285917
destmerge: extract logic based on branch heads in its own function
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
26727
diff
changeset
|
326 bheads = repo.branchheads(branch) |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
327 onhead = repo.revs(b'%ld and %ln', sourceset, bheads) |
28161
3324345a498e
destutil: ensure we offer 'hg update' hint when not at head in all cases
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
28141
diff
changeset
|
328 if onheadcheck and not onhead: |
28139
5476a7a039c0
destutil: allow to specify an explicit source for the merge
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
28138
diff
changeset
|
329 # Case A: working copy if not on a head. (merge only) |
28105
1fc7b5363871
destutil: document various failure cases
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
28104
diff
changeset
|
330 # |
1fc7b5363871
destutil: document various failure cases
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
28104
diff
changeset
|
331 # This is probably a user mistake We bailout pointing at 'hg update' |
28103
7d852bb47b0a
merge: give priority to "not at head" failures for bare 'hg merge'
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
28102
diff
changeset
|
332 if len(repo.heads()) <= 1: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
333 msg, hint = msgdestmerge[b'nootherheadsbehind'][action] |
28103
7d852bb47b0a
merge: give priority to "not at head" failures for bare 'hg merge'
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
28102
diff
changeset
|
334 else: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
335 msg, hint = msgdestmerge[b'notatheads'][action] |
28103
7d852bb47b0a
merge: give priority to "not at head" failures for bare 'hg merge'
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
28102
diff
changeset
|
336 raise error.Abort(msg, hint=hint) |
28139
5476a7a039c0
destutil: allow to specify an explicit source for the merge
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
28138
diff
changeset
|
337 # remove heads descendants of source from the set |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
338 bheads = list(repo.revs(b'%ln - (%ld::)', bheads, sourceset)) |
28138
5ad2017454ee
destutil: remove current head from list of candidates early
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
28137
diff
changeset
|
339 # filters out bookmarked heads |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
340 nbhs = list(repo.revs(b'%ld - bookmark()', bheads)) |
29043
cf7de4aeb86b
destutil: add the ability to specify a search space for rebase destination
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
28924
diff
changeset
|
341 |
cf7de4aeb86b
destutil: add the ability to specify a search space for rebase destination
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
28924
diff
changeset
|
342 if destspace is not None: |
cf7de4aeb86b
destutil: add the ability to specify a search space for rebase destination
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
28924
diff
changeset
|
343 # restrict search space |
cf7de4aeb86b
destutil: add the ability to specify a search space for rebase destination
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
28924
diff
changeset
|
344 # used in the 'hg pull --rebase' case, see issue 5214. |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
345 nbhs = list(repo.revs(b'%ld and %ld', destspace, nbhs)) |
29043
cf7de4aeb86b
destutil: add the ability to specify a search space for rebase destination
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
28924
diff
changeset
|
346 |
28138
5ad2017454ee
destutil: remove current head from list of candidates early
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
28137
diff
changeset
|
347 if len(nbhs) > 1: |
5ad2017454ee
destutil: remove current head from list of candidates early
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
28137
diff
changeset
|
348 # Case B: There is more than 1 other anonymous heads |
28105
1fc7b5363871
destutil: document various failure cases
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
28104
diff
changeset
|
349 # |
1fc7b5363871
destutil: document various failure cases
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
28104
diff
changeset
|
350 # This means that there will be more than 1 candidate. This is |
1fc7b5363871
destutil: document various failure cases
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
28104
diff
changeset
|
351 # ambiguous. We abort asking the user to pick as explicit destination |
1fc7b5363871
destutil: document various failure cases
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
28104
diff
changeset
|
352 # instead. |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
353 msg, hint = msgdestmerge[b'toomanyheads'][action] |
28138
5ad2017454ee
destutil: remove current head from list of candidates early
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
28137
diff
changeset
|
354 msg %= (branch, len(bheads) + 1) |
28141
13bb8de97f87
destutil: add more precise error classes for destmerge
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
28140
diff
changeset
|
355 raise error.ManyMergeDestAbort(msg, hint=hint) |
28138
5ad2017454ee
destutil: remove current head from list of candidates early
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
28137
diff
changeset
|
356 elif not nbhs: |
5ad2017454ee
destutil: remove current head from list of candidates early
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
28137
diff
changeset
|
357 # Case B: There is no other anonymous heads |
28105
1fc7b5363871
destutil: document various failure cases
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
28104
diff
changeset
|
358 # |
1fc7b5363871
destutil: document various failure cases
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
28104
diff
changeset
|
359 # This means that there is no natural candidate to merge with. |
1fc7b5363871
destutil: document various failure cases
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
28104
diff
changeset
|
360 # We abort, with various messages for various cases. |
28138
5ad2017454ee
destutil: remove current head from list of candidates early
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
28137
diff
changeset
|
361 if bheads: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
362 msg, hint = msgdestmerge[b'bookmarkedheads'][action] |
28102
bd74b5e0d2c0
destutil: extract all 'mergedest' abort messages into a dictionary
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
28065
diff
changeset
|
363 elif len(repo.heads()) > 1: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
364 msg, hint = msgdestmerge[b'nootherbranchheads'][action] |
28102
bd74b5e0d2c0
destutil: extract all 'mergedest' abort messages into a dictionary
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
28065
diff
changeset
|
365 msg %= branch |
28161
3324345a498e
destutil: ensure we offer 'hg update' hint when not at head in all cases
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
28141
diff
changeset
|
366 elif not onhead: |
3324345a498e
destutil: ensure we offer 'hg update' hint when not at head in all cases
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
28141
diff
changeset
|
367 # if 'onheadcheck == False' (rebase case), |
3324345a498e
destutil: ensure we offer 'hg update' hint when not at head in all cases
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
28141
diff
changeset
|
368 # this was not caught in Case A. |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
369 msg, hint = msgdestmerge[b'nootherheadsbehind'][action] |
28102
bd74b5e0d2c0
destutil: extract all 'mergedest' abort messages into a dictionary
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
28065
diff
changeset
|
370 else: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
371 msg, hint = msgdestmerge[b'nootherheads'][action] |
28141
13bb8de97f87
destutil: add more precise error classes for destmerge
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
28140
diff
changeset
|
372 raise error.NoMergeDestAbort(msg, hint=hint) |
26728
e8f1b7285917
destmerge: extract logic based on branch heads in its own function
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
26727
diff
changeset
|
373 else: |
e8f1b7285917
destmerge: extract logic based on branch heads in its own function
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
26727
diff
changeset
|
374 node = nbhs[0] |
e8f1b7285917
destmerge: extract logic based on branch heads in its own function
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
26727
diff
changeset
|
375 assert node is not None |
e8f1b7285917
destmerge: extract logic based on branch heads in its own function
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
26727
diff
changeset
|
376 return node |
e8f1b7285917
destmerge: extract logic based on branch heads in its own function
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
26727
diff
changeset
|
377 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
41146
diff
changeset
|
378 |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
41146
diff
changeset
|
379 def destmerge( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
380 repo, action=b'merge', sourceset=None, onheadcheck=True, destspace=None |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
41146
diff
changeset
|
381 ): |
28137
b54c0246295b
destutil: add an 'action' layer to the destmerge message dictionary
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
28105
diff
changeset
|
382 """return the default destination for a merge |
b54c0246295b
destutil: add an 'action' layer to the destmerge message dictionary
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
28105
diff
changeset
|
383 |
b54c0246295b
destutil: add an 'action' layer to the destmerge message dictionary
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
28105
diff
changeset
|
384 (or raise exception about why it can't pick one) |
b54c0246295b
destutil: add an 'action' layer to the destmerge message dictionary
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
28105
diff
changeset
|
385 |
b54c0246295b
destutil: add an 'action' layer to the destmerge message dictionary
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
28105
diff
changeset
|
386 :action: the action being performed, controls emitted error message |
b54c0246295b
destutil: add an 'action' layer to the destmerge message dictionary
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
28105
diff
changeset
|
387 """ |
29043
cf7de4aeb86b
destutil: add the ability to specify a search space for rebase destination
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
28924
diff
changeset
|
388 # destspace is here to work around issues with `hg pull --rebase` see |
cf7de4aeb86b
destutil: add the ability to specify a search space for rebase destination
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
28924
diff
changeset
|
389 # issue5214 for details |
26714
9903261dcc81
destutil: move default merge destination into a function
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
26683
diff
changeset
|
390 if repo._activebookmark: |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
41146
diff
changeset
|
391 node = _destmergebook( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
41146
diff
changeset
|
392 repo, action=action, sourceset=sourceset, destspace=destspace |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
41146
diff
changeset
|
393 ) |
26714
9903261dcc81
destutil: move default merge destination into a function
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
26683
diff
changeset
|
394 else: |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
41146
diff
changeset
|
395 node = _destmergebranch( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
41146
diff
changeset
|
396 repo, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
41146
diff
changeset
|
397 action=action, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
41146
diff
changeset
|
398 sourceset=sourceset, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
41146
diff
changeset
|
399 onheadcheck=onheadcheck, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
41146
diff
changeset
|
400 destspace=destspace, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
41146
diff
changeset
|
401 ) |
26714
9903261dcc81
destutil: move default merge destination into a function
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
26683
diff
changeset
|
402 return repo[node].rev() |
27262
3d0feb2f978b
histedit: pick an appropriate base changeset by default (BC)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26728
diff
changeset
|
403 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
41146
diff
changeset
|
404 |
27262
3d0feb2f978b
histedit: pick an appropriate base changeset by default (BC)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26728
diff
changeset
|
405 def desthistedit(ui, repo): |
3d0feb2f978b
histedit: pick an appropriate base changeset by default (BC)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26728
diff
changeset
|
406 """Default base revision to edit for `hg histedit`.""" |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
407 default = ui.config(b'histedit', b'defaultrev') |
37003
2987726085c6
histedit: use the new stack definition for histedit
Boris Feld <boris.feld@octobus.net>
parents:
37002
diff
changeset
|
408 |
2987726085c6
histedit: use the new stack definition for histedit
Boris Feld <boris.feld@octobus.net>
parents:
37002
diff
changeset
|
409 if default is None: |
2987726085c6
histedit: use the new stack definition for histedit
Boris Feld <boris.feld@octobus.net>
parents:
37002
diff
changeset
|
410 revs = stack.getstack(repo) |
2987726085c6
histedit: use the new stack definition for histedit
Boris Feld <boris.feld@octobus.net>
parents:
37002
diff
changeset
|
411 elif default: |
27559
d13bcc9fd656
destutil: use scmutil.revrange for desthistedit (issue5001)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27333
diff
changeset
|
412 revs = scmutil.revrange(repo, [default]) |
41146
fbd168455b26
histedit: crashing with a more useful error message on empty defaultrev
rdamazio@google.com
parents:
37787
diff
changeset
|
413 else: |
45843
c7abdbc8fd47
destutil: raise more specific error when histedit.defaultrev is empty
Martin von Zweigbergk <martinvonz@google.com>
parents:
43117
diff
changeset
|
414 raise error.ConfigError( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
415 _(b"config option histedit.defaultrev can't be empty") |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
416 ) |
37003
2987726085c6
histedit: use the new stack definition for histedit
Boris Feld <boris.feld@octobus.net>
parents:
37002
diff
changeset
|
417 |
2987726085c6
histedit: use the new stack definition for histedit
Boris Feld <boris.feld@octobus.net>
parents:
37002
diff
changeset
|
418 if revs: |
37390
b95992605ef1
histedit: simplify desthistedit
Boris Feld <boris.feld@octobus.net>
parents:
37375
diff
changeset
|
419 # Take the first revision of the revset as the root |
b95992605ef1
histedit: simplify desthistedit
Boris Feld <boris.feld@octobus.net>
parents:
37375
diff
changeset
|
420 return revs.min() |
27262
3d0feb2f978b
histedit: pick an appropriate base changeset by default (BC)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26728
diff
changeset
|
421 |
3d0feb2f978b
histedit: pick an appropriate base changeset by default (BC)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
26728
diff
changeset
|
422 return None |
28029
72072cfc7e91
update: warn about other topological heads on bare update
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
27559
diff
changeset
|
423 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
41146
diff
changeset
|
424 |
33197
c5a07a3abe7d
show: implement "stack" view
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33142
diff
changeset
|
425 def stackbase(ui, repo): |
37002
a72198790e15
show: use the new stack definition for show stack
Boris Feld <boris.feld@octobus.net>
parents:
33197
diff
changeset
|
426 revs = stack.getstack(repo) |
37004
68fcc5503ec5
stack: return a sorted smartrev by default
Boris Feld <boris.feld@octobus.net>
parents:
37003
diff
changeset
|
427 return revs.first() if revs else None |
33197
c5a07a3abe7d
show: implement "stack" view
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33142
diff
changeset
|
428 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
41146
diff
changeset
|
429 |
28029
72072cfc7e91
update: warn about other topological heads on bare update
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
27559
diff
changeset
|
430 def _statusotherbook(ui, repo): |
32381
b9942bc6b292
localrepo: extract bookmarkheads method to bookmarks.py
Augie Fackler <augie@google.com>
parents:
31025
diff
changeset
|
431 bmheads = bookmarks.headsforactive(repo) |
37452
2b38c80557a4
destutil: look up bookmarks only among bookmarks
Martin von Zweigbergk <martinvonz@google.com>
parents:
37390
diff
changeset
|
432 curhead = repo._bookmarks[repo._activebookmark] |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
433 if repo.revs(b'%n and parents()', curhead): |
28029
72072cfc7e91
update: warn about other topological heads on bare update
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
27559
diff
changeset
|
434 # we are on the active bookmark |
72072cfc7e91
update: warn about other topological heads on bare update
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
27559
diff
changeset
|
435 bmheads = [b for b in bmheads if curhead != b] |
72072cfc7e91
update: warn about other topological heads on bare update
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
27559
diff
changeset
|
436 if bmheads: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
437 msg = _(b'%i other divergent bookmarks for "%s"\n') |
28029
72072cfc7e91
update: warn about other topological heads on bare update
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
27559
diff
changeset
|
438 ui.status(msg % (len(bmheads), repo._activebookmark)) |
72072cfc7e91
update: warn about other topological heads on bare update
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
27559
diff
changeset
|
439 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
41146
diff
changeset
|
440 |
28029
72072cfc7e91
update: warn about other topological heads on bare update
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
27559
diff
changeset
|
441 def _statusotherbranchheads(ui, repo): |
72072cfc7e91
update: warn about other topological heads on bare update
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
27559
diff
changeset
|
442 currentbranch = repo.dirstate.branch() |
28266
de8b09482fb7
destutil: show message about other branch heads, even if on a closed head
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
28236
diff
changeset
|
443 allheads = repo.branchheads(currentbranch, closed=True) |
28029
72072cfc7e91
update: warn about other topological heads on bare update
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
27559
diff
changeset
|
444 heads = repo.branchheads(currentbranch) |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
445 if repo.revs(b'%ln and parents()', allheads): |
28266
de8b09482fb7
destutil: show message about other branch heads, even if on a closed head
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
28236
diff
changeset
|
446 # we are on a head, even though it might be closed |
28385
3f9e25a42e69
destutil: choose non-closed branch head at first (BC)
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
28266
diff
changeset
|
447 # |
3f9e25a42e69
destutil: choose non-closed branch head at first (BC)
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
28266
diff
changeset
|
448 # on closed otherheads |
3f9e25a42e69
destutil: choose non-closed branch head at first (BC)
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
28266
diff
changeset
|
449 # ========= ========== |
3f9e25a42e69
destutil: choose non-closed branch head at first (BC)
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
28266
diff
changeset
|
450 # o 0 all heads for current branch are closed |
3f9e25a42e69
destutil: choose non-closed branch head at first (BC)
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
28266
diff
changeset
|
451 # N only descendant branch heads are closed |
3f9e25a42e69
destutil: choose non-closed branch head at first (BC)
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
28266
diff
changeset
|
452 # x 0 there is only one non-closed branch head |
3f9e25a42e69
destutil: choose non-closed branch head at first (BC)
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
28266
diff
changeset
|
453 # N there are some non-closed branch heads |
3f9e25a42e69
destutil: choose non-closed branch head at first (BC)
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
28266
diff
changeset
|
454 # ========= ========== |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
455 otherheads = repo.revs(b'%ln - parents()', heads) |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
456 if repo[b'.'].closesbranch(): |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
41146
diff
changeset
|
457 ui.warn( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
41146
diff
changeset
|
458 _( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
459 b'no open descendant heads on branch "%s", ' |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
460 b'updating to a closed head\n' |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
41146
diff
changeset
|
461 ) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
41146
diff
changeset
|
462 % currentbranch |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
41146
diff
changeset
|
463 ) |
28385
3f9e25a42e69
destutil: choose non-closed branch head at first (BC)
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
28266
diff
changeset
|
464 if otherheads: |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
41146
diff
changeset
|
465 ui.warn( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
41146
diff
changeset
|
466 _( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
467 b"(committing will reopen the head, " |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
468 b"use 'hg heads .' to see %i other heads)\n" |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
41146
diff
changeset
|
469 ) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
41146
diff
changeset
|
470 % (len(otherheads)) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
41146
diff
changeset
|
471 ) |
28385
3f9e25a42e69
destutil: choose non-closed branch head at first (BC)
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
28266
diff
changeset
|
472 else: |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
41146
diff
changeset
|
473 ui.warn( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
474 _(b'(committing will reopen branch "%s")\n') % currentbranch |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
41146
diff
changeset
|
475 ) |
28385
3f9e25a42e69
destutil: choose non-closed branch head at first (BC)
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
28266
diff
changeset
|
476 elif otherheads: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
477 curhead = repo[b'.'] |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
41146
diff
changeset
|
478 ui.status( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
479 _(b'updated to "%s: %s"\n') |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
480 % (curhead, curhead.description().split(b'\n')[0]) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
41146
diff
changeset
|
481 ) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
41146
diff
changeset
|
482 ui.status( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
483 _(b'%i other heads for branch "%s"\n') |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
41146
diff
changeset
|
484 % (len(otherheads), currentbranch) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
41146
diff
changeset
|
485 ) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
41146
diff
changeset
|
486 |
28029
72072cfc7e91
update: warn about other topological heads on bare update
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
27559
diff
changeset
|
487 |
72072cfc7e91
update: warn about other topological heads on bare update
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
27559
diff
changeset
|
488 def statusotherdests(ui, repo): |
72072cfc7e91
update: warn about other topological heads on bare update
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
27559
diff
changeset
|
489 """Print message about other head""" |
72072cfc7e91
update: warn about other topological heads on bare update
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
27559
diff
changeset
|
490 # XXX we should probably include a hint: |
72072cfc7e91
update: warn about other topological heads on bare update
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
27559
diff
changeset
|
491 # - about what to do |
72072cfc7e91
update: warn about other topological heads on bare update
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
27559
diff
changeset
|
492 # - how to see such heads |
72072cfc7e91
update: warn about other topological heads on bare update
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
27559
diff
changeset
|
493 if repo._activebookmark: |
72072cfc7e91
update: warn about other topological heads on bare update
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
27559
diff
changeset
|
494 _statusotherbook(ui, repo) |
72072cfc7e91
update: warn about other topological heads on bare update
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
27559
diff
changeset
|
495 else: |
72072cfc7e91
update: warn about other topological heads on bare update
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
27559
diff
changeset
|
496 _statusotherbranchheads(ui, repo) |