annotate mercurial/destutil.py @ 34761:cb1ea7ef773d

configitems: register the 'patchbomb.cc' config
author Boris Feld <boris.feld@octobus.net>
date Fri, 13 Oct 2017 23:07:01 +0200
parents c5a07a3abe7d
children a72198790e15
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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 #
2aeeef1dc9a5 update: move default destination computation to a function
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
3 # Copyright Matt Mackall <mpm@selenic.com> and other
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
27333
2c60b4b2a0de destutil: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents: 27262
diff changeset
8 from __future__ import absolute_import
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 _
2aeeef1dc9a5 update: move default destination computation to a function
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
11 from . import (
26641
5c57d01fe64e destupdate: also include bookmark related logic
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 26629
diff changeset
12 bookmarks,
26569
2aeeef1dc9a5 update: move default destination computation to a function
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
13 error,
33142
4f49810a1011 obsutil: move 'successorssets' to the new modules
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 32698
diff changeset
14 obsutil,
31025
6cf2857526c7 scmutil: proxy revrange() through repo to break import cycles
Yuya Nishihara <yuya@tcha.org>
parents: 30962
diff changeset
15 scmutil,
26569
2aeeef1dc9a5 update: move default destination computation to a function
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
16 )
2aeeef1dc9a5 update: move default destination computation to a function
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
17
30962
11c253997b0e destutil: drop now-unused "check" parameter from destupdate()
Martin von Zweigbergk <martinvonz@google.com>
parents: 30961
diff changeset
18 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
19 """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
20 node = None
2aeeef1dc9a5 update: move default destination computation to a function
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
21 wc = repo[None]
2aeeef1dc9a5 update: move default destination computation to a function
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
22 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
23 movemark = None
26569
2aeeef1dc9a5 update: move default destination computation to a function
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
24
2aeeef1dc9a5 update: move default destination computation to a function
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
25 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
26 # 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
27 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
28
2aeeef1dc9a5 update: move default destination computation to a function
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
29 # 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
30 #
2aeeef1dc9a5 update: move default destination computation to a function
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
31 # 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
32 # 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
33 # (i.e. 'tip')
2aeeef1dc9a5 update: move default destination computation to a function
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
34 #
2aeeef1dc9a5 update: move default destination computation to a function
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
35 # 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
36 # is no conflict
2aeeef1dc9a5 update: move default destination computation to a function
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
37 #
2aeeef1dc9a5 update: move default destination computation to a function
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
38 # pruned changeset: no update is done; though, we could
2aeeef1dc9a5 update: move default destination computation to a function
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
39 # consider updating to the first non-obsolete parent,
2aeeef1dc9a5 update: move default destination computation to a function
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
40 # similar to what is current done for 'hg prune'
2aeeef1dc9a5 update: move default destination computation to a function
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
41
2aeeef1dc9a5 update: move default destination computation to a function
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
42 if successors:
2aeeef1dc9a5 update: move default destination computation to a function
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
43 # 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
44 # 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
45 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
46
2aeeef1dc9a5 update: move default destination computation to a function
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
47 # 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
48 # i.e. the 'tip' of a set
2aeeef1dc9a5 update: move default destination computation to a function
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff changeset
49 node = repo.revs('max(%ln)', successors).first()
26722
6cd643a1d32c destupdate: move obsolete handling first
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 26721
diff changeset
50 if bookmarks.isactivewdirparent(repo):
6cd643a1d32c destupdate: move obsolete handling first
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 26721
diff changeset
51 movemark = repo['.'].node()
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
52 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
53
30962
11c253997b0e destutil: drop now-unused "check" parameter from destupdate()
Martin von Zweigbergk <martinvonz@google.com>
parents: 30961
diff changeset
54 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
55 """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
56 # we also move the active bookmark, if any
7fc759c0c430 destupdate: extract logic based on bookmarks in its own function
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 26723
diff changeset
57 activemark = None
7fc759c0c430 destupdate: extract logic based on bookmarks in its own function
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 26723
diff changeset
58 node, movemark = bookmarks.calculateupdate(repo.ui, repo, None)
7fc759c0c430 destupdate: extract logic based on bookmarks in its own function
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 26723
diff changeset
59 if node is not None:
7fc759c0c430 destupdate: extract logic based on bookmarks in its own function
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 26723
diff changeset
60 activemark = node
7fc759c0c430 destupdate: extract logic based on bookmarks in its own function
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 26723
diff changeset
61 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
62
30962
11c253997b0e destutil: drop now-unused "check" parameter from destupdate()
Martin von Zweigbergk <martinvonz@google.com>
parents: 30961
diff changeset
63 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
64 """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
65
3f9e25a42e69 destutil: choose non-closed branch head at first (BC)
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 28266
diff changeset
66 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
67 """
26725
bde739aced83 destupdate: extract logic based on branch in its own function
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 26724
diff changeset
68 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
69 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
70 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
71
1c7167009936 update: fix bare --clean to work on new branch (issue5003) (BC)
liscju <piotr.listkiewicz@gmail.com>
parents: 29043
diff changeset
72 if clean:
1c7167009936 update: fix bare --clean to work on new branch (issue5003) (BC)
liscju <piotr.listkiewicz@gmail.com>
parents: 29043
diff changeset
73 currentbranch = repo['.'].branch()
1c7167009936 update: fix bare --clean to work on new branch (issue5003) (BC)
liscju <piotr.listkiewicz@gmail.com>
parents: 29043
diff changeset
74
28236
e333cea74741 destutil: use cached branch information instead of query for efficiency
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 28235
diff changeset
75 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
76 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
77 if heads:
e333cea74741 destutil: use cached branch information instead of query for efficiency
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 28235
diff changeset
78 node = repo.revs('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
79 if bookmarks.isactivewdirparent(repo):
bde739aced83 destupdate: extract logic based on branch in its own function
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 26724
diff changeset
80 movemark = repo['.'].node()
28924
d9539959167d update: resurrect bare update from null parent to tip-most branch head
Yuya Nishihara <yuya@tcha.org>
parents: 28903
diff changeset
81 elif currentbranch == 'default' and not wc.p1():
d9539959167d update: resurrect bare update from null parent to tip-most branch head
Yuya Nishihara <yuya@tcha.org>
parents: 28903
diff changeset
82 # "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
83 # update to the tipmost non-closed branch head
d9539959167d update: resurrect bare update from null parent to tip-most branch head
Yuya Nishihara <yuya@tcha.org>
parents: 28903
diff changeset
84 node = repo.revs('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
85 else:
28903
e1dd0de26557 update: fix bare update to work on new branch
liscju <piotr.listkiewicz@gmail.com>
parents: 28684
diff changeset
86 node = repo['.'].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
87 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
88
30962
11c253997b0e destutil: drop now-unused "check" parameter from destupdate()
Martin von Zweigbergk <martinvonz@google.com>
parents: 30961
diff changeset
89 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
90 """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
91 wc = repo[None]
3f9e25a42e69 destutil: choose non-closed branch head at first (BC)
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 28266
diff changeset
92 currentbranch = wc.branch()
3f9e25a42e69 destutil: choose non-closed branch head at first (BC)
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 28266
diff changeset
93 movemark = None
3f9e25a42e69 destutil: choose non-closed branch head at first (BC)
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 28266
diff changeset
94 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
95 # 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
96 heads = repo.branchheads(currentbranch, closed=True)
3f9e25a42e69 destutil: choose non-closed branch head at first (BC)
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 28266
diff changeset
97 assert heads, "any branch has at least one head"
3f9e25a42e69 destutil: choose non-closed branch head at first (BC)
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 28266
diff changeset
98 node = repo.revs('max(.::(%ln))', heads).first()
3f9e25a42e69 destutil: choose non-closed branch head at first (BC)
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 28266
diff changeset
99 assert node is not None, ("any revision has at least "
3f9e25a42e69 destutil: choose non-closed branch head at first (BC)
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 28266
diff changeset
100 "one descendant branch head")
3f9e25a42e69 destutil: choose non-closed branch head at first (BC)
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 28266
diff changeset
101 if bookmarks.isactivewdirparent(repo):
3f9e25a42e69 destutil: choose non-closed branch head at first (BC)
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 28266
diff changeset
102 movemark = repo['.'].node()
3f9e25a42e69 destutil: choose non-closed branch head at first (BC)
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 28266
diff changeset
103 else:
3f9e25a42e69 destutil: choose non-closed branch head at first (BC)
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 28266
diff changeset
104 # here, no "default" branch, and all branches are closed
3f9e25a42e69 destutil: choose non-closed branch head at first (BC)
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 28266
diff changeset
105 node = repo.lookup('tip')
3f9e25a42e69 destutil: choose non-closed branch head at first (BC)
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 28266
diff changeset
106 assert node is not None, "'tip' exists even in empty repository"
3f9e25a42e69 destutil: choose non-closed branch head at first (BC)
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 28266
diff changeset
107 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
108
30332
318a24b52eeb spelling: fixes of non-dictionary words
Mads Kiilerich <madski@unity3d.com>
parents: 29964
diff changeset
109 # 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
110 # steps are run until one finds a destination
28385
3f9e25a42e69 destutil: choose non-closed branch head at first (BC)
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 28266
diff changeset
111 destupdatesteps = ['evolution', 'bookmark', 'branch', '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
112 # mapping to ease extension overriding steps.
8e6649616699 destupdate: have a generic and extensible way to run each step
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 26725
diff changeset
113 destupdatestepmap = {'evolution': _destupdateobs,
8e6649616699 destupdate: have a generic and extensible way to run each step
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 26725
diff changeset
114 'bookmark': _destupdatebook,
8e6649616699 destupdate: have a generic and extensible way to run each step
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 26725
diff changeset
115 'branch': _destupdatebranch,
28385
3f9e25a42e69 destutil: choose non-closed branch head at first (BC)
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 28266
diff changeset
116 'branchfallback': _destupdatebranchfallback,
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
117 }
8e6649616699 destupdate: have a generic and extensible way to run each step
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 26725
diff changeset
118
30962
11c253997b0e destutil: drop now-unused "check" parameter from destupdate()
Martin von Zweigbergk <martinvonz@google.com>
parents: 30961
diff changeset
119 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
120 """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
121
52d08a93de1f destupdate: extract logic based on obsolescence marker in its own function
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 26722
diff changeset
122 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
123
52d08a93de1f destupdate: extract logic based on obsolescence marker in its own function
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 26722
diff changeset
124 - 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
125 - 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
126 (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
127 - 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
128 """
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
129 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
130
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
131 for step in destupdatesteps:
30962
11c253997b0e destutil: drop now-unused "check" parameter from destupdate()
Martin von Zweigbergk <martinvonz@google.com>
parents: 30961
diff changeset
132 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
133 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
134 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
135 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
136
26641
5c57d01fe64e destupdate: also include bookmark related logic
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 26629
diff changeset
137 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
138
28102
bd74b5e0d2c0 destutil: extract all 'mergedest' abort messages into a dictionary
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 28065
diff changeset
139 msgdestmerge = {
bd74b5e0d2c0 destutil: extract all 'mergedest' abort messages into a dictionary
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 28065
diff changeset
140 # too many matching divergent bookmark
bd74b5e0d2c0 destutil: extract all 'mergedest' abort messages into a dictionary
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 28065
diff changeset
141 'toomanybookmarks':
28137
b54c0246295b destutil: add an 'action' layer to the destmerge message dictionary
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 28105
diff changeset
142 {'merge':
b54c0246295b destutil: add an 'action' layer to the destmerge message dictionary
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 28105
diff changeset
143 (_("multiple matching bookmarks to merge -"
b54c0246295b destutil: add an 'action' layer to the destmerge message dictionary
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 28105
diff changeset
144 " please merge with an explicit rev or bookmark"),
b54c0246295b destutil: add an 'action' layer to the destmerge message dictionary
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 28105
diff changeset
145 _("run 'hg heads' to see all heads")),
28189
fac3a24be50e rebase: choose default destination the same way as 'hg merge' (BC)
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 28161
diff changeset
146 'rebase':
fac3a24be50e rebase: choose default destination the same way as 'hg merge' (BC)
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 28161
diff changeset
147 (_("multiple matching bookmarks to rebase -"
fac3a24be50e rebase: choose default destination the same way as 'hg merge' (BC)
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 28161
diff changeset
148 " please rebase to an explicit rev or bookmark"),
fac3a24be50e rebase: choose default destination the same way as 'hg merge' (BC)
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 28161
diff changeset
149 _("run 'hg heads' to see all heads")),
28137
b54c0246295b destutil: add an 'action' layer to the destmerge message dictionary
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 28105
diff changeset
150 },
28102
bd74b5e0d2c0 destutil: extract all 'mergedest' abort messages into a dictionary
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 28065
diff changeset
151 # no other matching divergent bookmark
bd74b5e0d2c0 destutil: extract all 'mergedest' abort messages into a dictionary
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 28065
diff changeset
152 'nootherbookmarks':
28137
b54c0246295b destutil: add an 'action' layer to the destmerge message dictionary
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 28105
diff changeset
153 {'merge':
b54c0246295b destutil: add an 'action' layer to the destmerge message dictionary
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 28105
diff changeset
154 (_("no matching bookmark to merge - "
b54c0246295b destutil: add an 'action' layer to the destmerge message dictionary
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 28105
diff changeset
155 "please merge with an explicit rev or bookmark"),
b54c0246295b destutil: add an 'action' layer to the destmerge message dictionary
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 28105
diff changeset
156 _("run 'hg heads' to see all heads")),
28189
fac3a24be50e rebase: choose default destination the same way as 'hg merge' (BC)
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 28161
diff changeset
157 'rebase':
fac3a24be50e rebase: choose default destination the same way as 'hg merge' (BC)
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 28161
diff changeset
158 (_("no matching bookmark to rebase - "
fac3a24be50e rebase: choose default destination the same way as 'hg merge' (BC)
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 28161
diff changeset
159 "please rebase to an explicit rev or bookmark"),
fac3a24be50e rebase: choose default destination the same way as 'hg merge' (BC)
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 28161
diff changeset
160 _("run 'hg heads' to see all heads")),
28137
b54c0246295b destutil: add an 'action' layer to the destmerge message dictionary
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 28105
diff changeset
161 },
28102
bd74b5e0d2c0 destutil: extract all 'mergedest' abort messages into a dictionary
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 28065
diff changeset
162 # branch have too many unbookmarked heads, no obvious destination
bd74b5e0d2c0 destutil: extract all 'mergedest' abort messages into a dictionary
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 28065
diff changeset
163 'toomanyheads':
28137
b54c0246295b destutil: add an 'action' layer to the destmerge message dictionary
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 28105
diff changeset
164 {'merge':
b54c0246295b destutil: add an 'action' layer to the destmerge message dictionary
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 28105
diff changeset
165 (_("branch '%s' has %d heads - please merge with an explicit rev"),
b54c0246295b destutil: add an 'action' layer to the destmerge message dictionary
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 28105
diff changeset
166 _("run 'hg heads .' to see heads")),
28189
fac3a24be50e rebase: choose default destination the same way as 'hg merge' (BC)
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 28161
diff changeset
167 'rebase':
fac3a24be50e rebase: choose default destination the same way as 'hg merge' (BC)
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 28161
diff changeset
168 (_("branch '%s' has %d heads - please rebase to an explicit rev"),
fac3a24be50e rebase: choose default destination the same way as 'hg merge' (BC)
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 28161
diff changeset
169 _("run 'hg heads .' to see heads")),
28137
b54c0246295b destutil: add an 'action' layer to the destmerge message dictionary
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 28105
diff changeset
170 },
28102
bd74b5e0d2c0 destutil: extract all 'mergedest' abort messages into a dictionary
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 28065
diff changeset
171 # branch have no other unbookmarked heads
bd74b5e0d2c0 destutil: extract all 'mergedest' abort messages into a dictionary
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 28065
diff changeset
172 'bookmarkedheads':
28137
b54c0246295b destutil: add an 'action' layer to the destmerge message dictionary
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 28105
diff changeset
173 {'merge':
b54c0246295b destutil: add an 'action' layer to the destmerge message dictionary
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 28105
diff changeset
174 (_("heads are bookmarked - please merge with an explicit rev"),
b54c0246295b destutil: add an 'action' layer to the destmerge message dictionary
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 28105
diff changeset
175 _("run 'hg heads' to see all heads")),
28189
fac3a24be50e rebase: choose default destination the same way as 'hg merge' (BC)
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 28161
diff changeset
176 'rebase':
fac3a24be50e rebase: choose default destination the same way as 'hg merge' (BC)
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 28161
diff changeset
177 (_("heads are bookmarked - please rebase to an explicit rev"),
fac3a24be50e rebase: choose default destination the same way as 'hg merge' (BC)
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 28161
diff changeset
178 _("run 'hg heads' to see all heads")),
28137
b54c0246295b destutil: add an 'action' layer to the destmerge message dictionary
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 28105
diff changeset
179 },
28102
bd74b5e0d2c0 destutil: extract all 'mergedest' abort messages into a dictionary
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 28065
diff changeset
180 # branch have just a single heads, but there is other branches
bd74b5e0d2c0 destutil: extract all 'mergedest' abort messages into a dictionary
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 28065
diff changeset
181 'nootherbranchheads':
28137
b54c0246295b destutil: add an 'action' layer to the destmerge message dictionary
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 28105
diff changeset
182 {'merge':
b54c0246295b destutil: add an 'action' layer to the destmerge message dictionary
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 28105
diff changeset
183 (_("branch '%s' has one head - please merge with an explicit rev"),
b54c0246295b destutil: add an 'action' layer to the destmerge message dictionary
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 28105
diff changeset
184 _("run 'hg heads' to see all heads")),
28189
fac3a24be50e rebase: choose default destination the same way as 'hg merge' (BC)
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 28161
diff changeset
185 'rebase':
fac3a24be50e rebase: choose default destination the same way as 'hg merge' (BC)
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 28161
diff changeset
186 (_("branch '%s' has one head - please rebase to an explicit rev"),
fac3a24be50e rebase: choose default destination the same way as 'hg merge' (BC)
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 28161
diff changeset
187 _("run 'hg heads' to see all heads")),
28137
b54c0246295b destutil: add an 'action' layer to the destmerge message dictionary
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 28105
diff changeset
188 },
28102
bd74b5e0d2c0 destutil: extract all 'mergedest' abort messages into a dictionary
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 28065
diff changeset
189 # repository have a single head
bd74b5e0d2c0 destutil: extract all 'mergedest' abort messages into a dictionary
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 28065
diff changeset
190 'nootherheads':
28189
fac3a24be50e rebase: choose default destination the same way as 'hg merge' (BC)
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 28161
diff changeset
191 {'merge':
fac3a24be50e rebase: choose default destination the same way as 'hg merge' (BC)
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 28161
diff changeset
192 (_('nothing to merge'),
fac3a24be50e rebase: choose default destination the same way as 'hg merge' (BC)
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 28161
diff changeset
193 None),
fac3a24be50e rebase: choose default destination the same way as 'hg merge' (BC)
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 28161
diff changeset
194 'rebase':
fac3a24be50e rebase: choose default destination the same way as 'hg merge' (BC)
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 28161
diff changeset
195 (_('nothing to rebase'),
fac3a24be50e rebase: choose default destination the same way as 'hg merge' (BC)
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 28161
diff changeset
196 None),
28137
b54c0246295b destutil: add an 'action' layer to the destmerge message dictionary
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 28105
diff changeset
197 },
28102
bd74b5e0d2c0 destutil: extract all 'mergedest' abort messages into a dictionary
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 28065
diff changeset
198 # repository have a single head and we are not on it
bd74b5e0d2c0 destutil: extract all 'mergedest' abort messages into a dictionary
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 28065
diff changeset
199 'nootherheadsbehind':
28137
b54c0246295b destutil: add an 'action' layer to the destmerge message dictionary
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 28105
diff changeset
200 {'merge':
b54c0246295b destutil: add an 'action' layer to the destmerge message dictionary
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 28105
diff changeset
201 (_('nothing to merge'),
b54c0246295b destutil: add an 'action' layer to the destmerge message dictionary
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 28105
diff changeset
202 _("use 'hg update' instead")),
28189
fac3a24be50e rebase: choose default destination the same way as 'hg merge' (BC)
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 28161
diff changeset
203 'rebase':
fac3a24be50e rebase: choose default destination the same way as 'hg merge' (BC)
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 28161
diff changeset
204 (_('nothing to rebase'),
fac3a24be50e rebase: choose default destination the same way as 'hg merge' (BC)
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 28161
diff changeset
205 _("use 'hg update' instead")),
28137
b54c0246295b destutil: add an 'action' layer to the destmerge message dictionary
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 28105
diff changeset
206 },
28102
bd74b5e0d2c0 destutil: extract all 'mergedest' abort messages into a dictionary
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 28065
diff changeset
207 # We are not on a head
bd74b5e0d2c0 destutil: extract all 'mergedest' abort messages into a dictionary
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 28065
diff changeset
208 'notatheads':
28137
b54c0246295b destutil: add an 'action' layer to the destmerge message dictionary
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 28105
diff changeset
209 {'merge':
b54c0246295b destutil: add an 'action' layer to the destmerge message dictionary
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 28105
diff changeset
210 (_('working directory not at a head revision'),
28189
fac3a24be50e rebase: choose default destination the same way as 'hg merge' (BC)
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 28161
diff changeset
211 _("use 'hg update' or merge with an explicit revision")),
fac3a24be50e rebase: choose default destination the same way as 'hg merge' (BC)
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 28161
diff changeset
212 'rebase':
fac3a24be50e rebase: choose default destination the same way as 'hg merge' (BC)
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 28161
diff changeset
213 (_('working directory not at a head revision'),
fac3a24be50e rebase: choose default destination the same way as 'hg merge' (BC)
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 28161
diff changeset
214 _("use 'hg update' or rebase to an explicit revision"))
28137
b54c0246295b destutil: add an 'action' layer to the destmerge message dictionary
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 28105
diff changeset
215 },
28139
5476a7a039c0 destutil: allow to specify an explicit source for the merge
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 28138
diff changeset
216 'emptysourceset':
5476a7a039c0 destutil: allow to specify an explicit source for the merge
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 28138
diff changeset
217 {'merge':
5476a7a039c0 destutil: allow to specify an explicit source for the merge
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 28138
diff changeset
218 (_('source set is empty'),
28189
fac3a24be50e rebase: choose default destination the same way as 'hg merge' (BC)
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 28161
diff changeset
219 None),
fac3a24be50e rebase: choose default destination the same way as 'hg merge' (BC)
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 28161
diff changeset
220 'rebase':
fac3a24be50e rebase: choose default destination the same way as 'hg merge' (BC)
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 28161
diff changeset
221 (_('source set is empty'),
fac3a24be50e rebase: choose default destination the same way as 'hg merge' (BC)
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 28161
diff changeset
222 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
223 },
5476a7a039c0 destutil: allow to specify an explicit source for the merge
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 28138
diff changeset
224 'multiplebranchessourceset':
5476a7a039c0 destutil: allow to specify an explicit source for the merge
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 28138
diff changeset
225 {'merge':
5476a7a039c0 destutil: allow to specify an explicit source for the merge
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 28138
diff changeset
226 (_('source set is rooted in multiple branches'),
28189
fac3a24be50e rebase: choose default destination the same way as 'hg merge' (BC)
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 28161
diff changeset
227 None),
fac3a24be50e rebase: choose default destination the same way as 'hg merge' (BC)
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 28161
diff changeset
228 'rebase':
fac3a24be50e rebase: choose default destination the same way as 'hg merge' (BC)
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 28161
diff changeset
229 (_('rebaseset is rooted in multiple named branches'),
fac3a24be50e rebase: choose default destination the same way as 'hg merge' (BC)
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 28161
diff changeset
230 _('specify an explicit destination with --dest')),
28139
5476a7a039c0 destutil: allow to specify an explicit source for the merge
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 28138
diff changeset
231 },
28137
b54c0246295b destutil: add an 'action' layer to the destmerge message dictionary
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 28105
diff changeset
232 }
28102
bd74b5e0d2c0 destutil: extract all 'mergedest' abort messages into a dictionary
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 28065
diff changeset
233
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
234 def _destmergebook(repo, action='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
235 """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
236 node = None
32381
b9942bc6b292 localrepo: extract bookmarkheads method to bookmarks.py
Augie Fackler <augie@google.com>
parents: 31025
diff changeset
237 bmheads = bookmarks.headsforactive(repo)
26727
5b7fd48f9868 destmerge: extract logic based on bookmark into its own function
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 26726
diff changeset
238 curhead = repo[repo._activebookmark].node()
5b7fd48f9868 destmerge: extract logic based on bookmark into its own function
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 26726
diff changeset
239 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
240 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
241 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
242 else:
5b7fd48f9868 destmerge: extract logic based on bookmark into its own function
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 26726
diff changeset
243 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
244 elif len(bmheads) > 2:
28137
b54c0246295b destutil: add an 'action' layer to the destmerge message dictionary
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 28105
diff changeset
245 msg, hint = msgdestmerge['toomanybookmarks'][action]
28141
13bb8de97f87 destutil: add more precise error classes for destmerge
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 28140
diff changeset
246 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
247 elif len(bmheads) <= 1:
28137
b54c0246295b destutil: add an 'action' layer to the destmerge message dictionary
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 28105
diff changeset
248 msg, hint = msgdestmerge['nootherbookmarks'][action]
28141
13bb8de97f87 destutil: add more precise error classes for destmerge
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 28140
diff changeset
249 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
250 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
251 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
252
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
253 def _destmergebranch(repo, action='merge', sourceset=None, onheadcheck=True,
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
254 destspace=None):
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
255 """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
256 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
257
5476a7a039c0 destutil: allow to specify an explicit source for the merge
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 28138
diff changeset
258 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
259 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
260 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
261 elif not sourceset:
5476a7a039c0 destutil: allow to specify an explicit source for the merge
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 28138
diff changeset
262 msg, hint = msgdestmerge['emptysourceset'][action]
28141
13bb8de97f87 destutil: add more precise error classes for destmerge
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 28140
diff changeset
263 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
264 else:
5476a7a039c0 destutil: allow to specify an explicit source for the merge
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 28138
diff changeset
265 branch = None
5476a7a039c0 destutil: allow to specify an explicit source for the merge
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 28138
diff changeset
266 for ctx in repo.set('roots(%ld::%ld)', sourceset, sourceset):
5476a7a039c0 destutil: allow to specify an explicit source for the merge
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 28138
diff changeset
267 if branch is not None and ctx.branch() != branch:
5476a7a039c0 destutil: allow to specify an explicit source for the merge
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 28138
diff changeset
268 msg, hint = msgdestmerge['multiplebranchessourceset'][action]
28141
13bb8de97f87 destutil: add more precise error classes for destmerge
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 28140
diff changeset
269 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
270 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
271
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
272 bheads = repo.branchheads(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
273 onhead = repo.revs('%ld and %ln', sourceset, bheads)
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
274 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
275 # 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
276 #
1fc7b5363871 destutil: document various failure cases
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 28104
diff changeset
277 # 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
278 if len(repo.heads()) <= 1:
28137
b54c0246295b destutil: add an 'action' layer to the destmerge message dictionary
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 28105
diff changeset
279 msg, hint = msgdestmerge['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
280 else:
28137
b54c0246295b destutil: add an 'action' layer to the destmerge message dictionary
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 28105
diff changeset
281 msg, hint = msgdestmerge['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
282 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
283 # remove heads descendants of source from the set
5476a7a039c0 destutil: allow to specify an explicit source for the merge
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 28138
diff changeset
284 bheads = list(repo.revs('%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
285 # filters out bookmarked heads
28139
5476a7a039c0 destutil: allow to specify an explicit source for the merge
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 28138
diff changeset
286 nbhs = list(repo.revs('%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
287
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
288 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
289 # 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
290 # used in the 'hg pull --rebase' case, see issue 5214.
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
291 nbhs = list(repo.revs('%ld and %ld', destspace, nbhs))
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
292
28138
5ad2017454ee destutil: remove current head from list of candidates early
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 28137
diff changeset
293 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
294 # 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
295 #
1fc7b5363871 destutil: document various failure cases
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 28104
diff changeset
296 # 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
297 # 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
298 # instead.
28137
b54c0246295b destutil: add an 'action' layer to the destmerge message dictionary
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 28105
diff changeset
299 msg, hint = msgdestmerge['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
300 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
301 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
302 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
303 # 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
304 #
1fc7b5363871 destutil: document various failure cases
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 28104
diff changeset
305 # 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
306 # 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
307 if bheads:
28137
b54c0246295b destutil: add an 'action' layer to the destmerge message dictionary
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 28105
diff changeset
308 msg, hint = msgdestmerge['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
309 elif len(repo.heads()) > 1:
28137
b54c0246295b destutil: add an 'action' layer to the destmerge message dictionary
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 28105
diff changeset
310 msg, hint = msgdestmerge['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
311 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
312 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
313 # 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
314 # this was not caught in Case A.
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
315 msg, hint = msgdestmerge['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
316 else:
28137
b54c0246295b destutil: add an 'action' layer to the destmerge message dictionary
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 28105
diff changeset
317 msg, hint = msgdestmerge['nootherheads'][action]
28141
13bb8de97f87 destutil: add more precise error classes for destmerge
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 28140
diff changeset
318 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
319 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
320 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
321 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
322 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
323
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
324 def destmerge(repo, action='merge', sourceset=None, onheadcheck=True,
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
325 destspace=None):
28137
b54c0246295b destutil: add an 'action' layer to the destmerge message dictionary
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 28105
diff changeset
326 """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
327
b54c0246295b destutil: add an 'action' layer to the destmerge message dictionary
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 28105
diff changeset
328 (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
329
b54c0246295b destutil: add an 'action' layer to the destmerge message dictionary
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 28105
diff changeset
330 :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
331 """
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
332 # 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
333 # 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
334 if repo._activebookmark:
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
335 node = _destmergebook(repo, action=action, sourceset=sourceset,
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
336 destspace=destspace)
26714
9903261dcc81 destutil: move default merge destination into a function
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 26683
diff changeset
337 else:
28140
276644ae9e8d destutil: allow to disable the "on head check" in destmerge
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 28139
diff changeset
338 node = _destmergebranch(repo, action=action, sourceset=sourceset,
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
339 onheadcheck=onheadcheck, destspace=destspace)
26714
9903261dcc81 destutil: move default merge destination into a function
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 26683
diff changeset
340 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
341
3d0feb2f978b histedit: pick an appropriate base changeset by default (BC)
Gregory Szorc <gregory.szorc@gmail.com>
parents: 26728
diff changeset
342 histeditdefaultrevset = 'reverse(only(.) and not public() and not ::merge())'
3d0feb2f978b histedit: pick an appropriate base changeset by default (BC)
Gregory Szorc <gregory.szorc@gmail.com>
parents: 26728
diff changeset
343
3d0feb2f978b histedit: pick an appropriate base changeset by default (BC)
Gregory Szorc <gregory.szorc@gmail.com>
parents: 26728
diff changeset
344 def desthistedit(ui, repo):
3d0feb2f978b histedit: pick an appropriate base changeset by default (BC)
Gregory Szorc <gregory.szorc@gmail.com>
parents: 26728
diff changeset
345 """Default base revision to edit for `hg histedit`."""
3d0feb2f978b histedit: pick an appropriate base changeset by default (BC)
Gregory Szorc <gregory.szorc@gmail.com>
parents: 26728
diff changeset
346 default = ui.config('histedit', 'defaultrev', histeditdefaultrevset)
3d0feb2f978b histedit: pick an appropriate base changeset by default (BC)
Gregory Szorc <gregory.szorc@gmail.com>
parents: 26728
diff changeset
347 if default:
27559
d13bcc9fd656 destutil: use scmutil.revrange for desthistedit (issue5001)
Gregory Szorc <gregory.szorc@gmail.com>
parents: 27333
diff changeset
348 revs = scmutil.revrange(repo, [default])
27262
3d0feb2f978b histedit: pick an appropriate base changeset by default (BC)
Gregory Szorc <gregory.szorc@gmail.com>
parents: 26728
diff changeset
349 if revs:
3d0feb2f978b histedit: pick an appropriate base changeset by default (BC)
Gregory Szorc <gregory.szorc@gmail.com>
parents: 26728
diff changeset
350 # The revset supplied by the user may not be in ascending order nor
3d0feb2f978b histedit: pick an appropriate base changeset by default (BC)
Gregory Szorc <gregory.szorc@gmail.com>
parents: 26728
diff changeset
351 # take the first revision. So do this manually.
3d0feb2f978b histedit: pick an appropriate base changeset by default (BC)
Gregory Szorc <gregory.szorc@gmail.com>
parents: 26728
diff changeset
352 revs.sort()
3d0feb2f978b histedit: pick an appropriate base changeset by default (BC)
Gregory Szorc <gregory.szorc@gmail.com>
parents: 26728
diff changeset
353 return revs.first()
3d0feb2f978b histedit: pick an appropriate base changeset by default (BC)
Gregory Szorc <gregory.szorc@gmail.com>
parents: 26728
diff changeset
354
3d0feb2f978b histedit: pick an appropriate base changeset by default (BC)
Gregory Szorc <gregory.szorc@gmail.com>
parents: 26728
diff changeset
355 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
356
33197
c5a07a3abe7d show: implement "stack" view
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33142
diff changeset
357 def stackbase(ui, repo):
c5a07a3abe7d show: implement "stack" view
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33142
diff changeset
358 # The histedit default base stops at public changesets, branchpoints,
c5a07a3abe7d show: implement "stack" view
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33142
diff changeset
359 # and merges, which is exactly what we want for a stack.
c5a07a3abe7d show: implement "stack" view
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33142
diff changeset
360 revs = scmutil.revrange(repo, [histeditdefaultrevset])
c5a07a3abe7d show: implement "stack" view
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33142
diff changeset
361 return revs.last() if revs else None
c5a07a3abe7d show: implement "stack" view
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33142
diff changeset
362
28029
72072cfc7e91 update: warn about other topological heads on bare update
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 27559
diff changeset
363 def _statusotherbook(ui, repo):
32381
b9942bc6b292 localrepo: extract bookmarkheads method to bookmarks.py
Augie Fackler <augie@google.com>
parents: 31025
diff changeset
364 bmheads = bookmarks.headsforactive(repo)
28029
72072cfc7e91 update: warn about other topological heads on bare update
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 27559
diff changeset
365 curhead = repo[repo._activebookmark].node()
72072cfc7e91 update: warn about other topological heads on bare update
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 27559
diff changeset
366 if repo.revs('%n and parents()', curhead):
72072cfc7e91 update: warn about other topological heads on bare update
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 27559
diff changeset
367 # 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
368 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
369 if bmheads:
72072cfc7e91 update: warn about other topological heads on bare update
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 27559
diff changeset
370 msg = _('%i other divergent bookmarks for "%s"\n')
72072cfc7e91 update: warn about other topological heads on bare update
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 27559
diff changeset
371 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
372
72072cfc7e91 update: warn about other topological heads on bare update
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 27559
diff changeset
373 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
374 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
375 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
376 heads = repo.branchheads(currentbranch)
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
377 if repo.revs('%ln and parents()', allheads):
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
378 # 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
379 #
3f9e25a42e69 destutil: choose non-closed branch head at first (BC)
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 28266
diff changeset
380 # on closed otherheads
3f9e25a42e69 destutil: choose non-closed branch head at first (BC)
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 28266
diff changeset
381 # ========= ==========
3f9e25a42e69 destutil: choose non-closed branch head at first (BC)
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 28266
diff changeset
382 # 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
383 # 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
384 # 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
385 # 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
386 # ========= ==========
28233
9da2283d0c56 destutil: add new local variable to increase readability
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 28189
diff changeset
387 otherheads = repo.revs('%ln - parents()', heads)
28385
3f9e25a42e69 destutil: choose non-closed branch head at first (BC)
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 28266
diff changeset
388 if repo['.'].closesbranch():
28684
1ace17e1e160 destutil: show message and hint at updating to the closed head as warning
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 28683
diff changeset
389 ui.warn(_('no open descendant heads on branch "%s", '
28683
d0210a35c81a destutil: make messages at updating to the closed head usual form
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 28385
diff changeset
390 'updating to a closed head\n') %
d0210a35c81a destutil: make messages at updating to the closed head usual form
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 28385
diff changeset
391 (currentbranch))
28385
3f9e25a42e69 destutil: choose non-closed branch head at first (BC)
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 28266
diff changeset
392 if otherheads:
29964
40f845537dca update: use single quotes in use warning
timeless <timeless@mozdev.org>
parents: 29284
diff changeset
393 ui.warn(_("(committing will reopen the head, "
40f845537dca update: use single quotes in use warning
timeless <timeless@mozdev.org>
parents: 29284
diff changeset
394 "use 'hg heads .' to see %i other heads)\n") %
28683
d0210a35c81a destutil: make messages at updating to the closed head usual form
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 28385
diff changeset
395 (len(otherheads)))
28385
3f9e25a42e69 destutil: choose non-closed branch head at first (BC)
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 28266
diff changeset
396 else:
28684
1ace17e1e160 destutil: show message and hint at updating to the closed head as warning
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 28683
diff changeset
397 ui.warn(_('(committing will reopen branch "%s")\n') %
28683
d0210a35c81a destutil: make messages at updating to the closed head usual form
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 28385
diff changeset
398 (currentbranch))
28385
3f9e25a42e69 destutil: choose non-closed branch head at first (BC)
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 28266
diff changeset
399 elif otherheads:
32698
1b5c61d38a52 update: show the commit to which we updated in case of multiple heads (BC)
Pulkit Goyal <7895pulkit@gmail.com>
parents: 32381
diff changeset
400 curhead = repo['.']
1b5c61d38a52 update: show the commit to which we updated in case of multiple heads (BC)
Pulkit Goyal <7895pulkit@gmail.com>
parents: 32381
diff changeset
401 ui.status(_('updated to "%s: %s"\n') % (curhead,
1b5c61d38a52 update: show the commit to which we updated in case of multiple heads (BC)
Pulkit Goyal <7895pulkit@gmail.com>
parents: 32381
diff changeset
402 curhead.description().split('\n')[0]))
28029
72072cfc7e91 update: warn about other topological heads on bare update
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 27559
diff changeset
403 ui.status(_('%i other heads for branch "%s"\n') %
28233
9da2283d0c56 destutil: add new local variable to increase readability
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 28189
diff changeset
404 (len(otherheads), currentbranch))
28029
72072cfc7e91 update: warn about other topological heads on bare update
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 27559
diff changeset
405
72072cfc7e91 update: warn about other topological heads on bare update
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 27559
diff changeset
406 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
407 """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
408 # 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
409 # - 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
410 # - 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
411 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
412 _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
413 else:
72072cfc7e91 update: warn about other topological heads on bare update
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 27559
diff changeset
414 _statusotherbranchheads(ui, repo)