equal
deleted
inserted
replaced
20 hg, |
20 hg, |
21 lock as lockmod, |
21 lock as lockmod, |
22 node, |
22 node, |
23 obsolete, |
23 obsolete, |
24 obsutil, |
24 obsutil, |
25 phases, |
|
26 revset, |
25 revset, |
27 util, |
26 util, |
28 ) |
27 ) |
29 |
28 |
30 from mercurial.i18n import _ |
29 from mercurial.i18n import _ |
121 precheck(repo, revs, action=b'fold') |
120 precheck(repo, revs, action=b'fold') |
122 roots = repo.revs(b'roots(%ld)', revs) |
121 roots = repo.revs(b'roots(%ld)', revs) |
123 if len(roots) > 1: |
122 if len(roots) > 1: |
124 raise error.Abort(_(b"cannot fold non-linear revisions " |
123 raise error.Abort(_(b"cannot fold non-linear revisions " |
125 b"(multiple roots given)")) |
124 b"(multiple roots given)")) |
126 root = repo[roots.first()] |
|
127 if root.phase() <= phases.public: |
|
128 raise error.Abort(_(b"cannot fold public revisions")) |
|
129 heads = repo.revs(b'heads(%ld)', revs) |
125 heads = repo.revs(b'heads(%ld)', revs) |
130 if len(heads) > 1: |
126 if len(heads) > 1: |
131 raise error.Abort(_(b"cannot fold non-linear revisions " |
127 raise error.Abort(_(b"cannot fold non-linear revisions " |
132 b"(multiple heads given)")) |
128 b"(multiple heads given)")) |
133 head = repo[heads.first()] |
129 head = repo[heads.first()] |
140 if obsolete: |
136 if obsolete: |
141 msg = _(b'folding obsolete revisions may cause divergence') |
137 msg = _(b'folding obsolete revisions may cause divergence') |
142 hint = _(b'set experimental.evolution.allowdivergence=yes' |
138 hint = _(b'set experimental.evolution.allowdivergence=yes' |
143 b' to allow folding them') |
139 b' to allow folding them') |
144 raise error.Abort(msg, hint=hint) |
140 raise error.Abort(msg, hint=hint) |
|
141 root = repo[roots.first()] |
145 # root's p1 is already used as the target ctx p1 |
142 # root's p1 is already used as the target ctx p1 |
146 baseparents -= {root.p1().rev()} |
143 baseparents -= {root.p1().rev()} |
147 p2 = repo[baseparents.first()] |
144 p2 = repo[baseparents.first()] |
148 return root, head, p2 |
145 return root, head, p2 |
149 |
146 |