19 from mercurial import phases |
19 from mercurial import phases |
20 from mercurial import context |
20 from mercurial import context |
21 from mercurial import commands |
21 from mercurial import commands |
22 from mercurial import util |
22 from mercurial import util |
23 from mercurial.i18n import _ |
23 from mercurial.i18n import _ |
24 from mercurial.commands import walkopts, commitopts, commitopts2, logopts |
24 from mercurial.commands import walkopts, commitopts, commitopts2, logopt |
|
25 from mercurial import hg |
25 |
26 |
26 ### util function |
27 ### util function |
27 ############################# |
28 ############################# |
28 def noderange(repo, revsets): |
29 def noderange(repo, revsets): |
29 """The same as revrange but return node""" |
30 """The same as revrange but return node""" |
168 assert obs.obsolete() |
169 assert obs.obsolete() |
169 newer = obsolete.newerversion(repo, obs.node()) |
170 newer = obsolete.newerversion(repo, obs.node()) |
170 target = newer[-1] |
171 target = newer[-1] |
171 repo.ui.status('hg relocate --rev %s %s\n' % (repo[next], repo[target])) |
172 repo.ui.status('hg relocate --rev %s %s\n' % (repo[next], repo[target])) |
172 |
173 |
173 @command('^relocate', |
174 shorttemplate = '[{rev}] {desc|firstline}\n' |
174 [ |
175 |
175 ('r', 'rev', '.', |
176 @command('^gdown', |
176 _('revision to relocate')), |
177 [], |
177 ], |
178 'update to working directory parent an display summary lines') |
178 '') |
179 def cmdgdown(ui, repo): |
179 def cmdrelocate(ui, repo, dest, rev='.'): |
180 wkctx = repo[None] |
180 """relocate a changeset""" |
181 wparents = wkctx.parents() |
181 wlock = repo.wlock() |
182 if len(wparents) != 1: |
182 try: |
183 raise util.Abort('merge in progress') |
183 src = scmutil.revsingle(repo, rev, rev) |
184 |
184 dest = scmutil.revsingle(repo, dest, dest) |
185 parents = wparents[0].parents() |
185 if src == src.ancestor(dest): |
186 displayer = cmdutil.show_changeset(ui, repo, {'template': shorttemplate}) |
186 raise util.Abort(_('source is ancestor of destination')) |
187 if len(parents) == 1: |
187 relocate(repo, src.rev(), dest.rev()) |
188 p = parents[0] |
|
189 hg.update(repo, p.rev()) |
|
190 displayer.show(p) |
188 return 0 |
191 return 0 |
189 finally: |
192 else: |
190 wlock.release() |
193 for p in parents: |
191 |
194 displayer.show(p) |
|
195 ui.warn(_('multiple parents, explicitly update to one\n')) |
|
196 return 1 |
|
197 |
|
198 @command('^gup', |
|
199 [], |
|
200 'update to working directory children an display summary lines') |
|
201 def cmdup(ui, repo): |
|
202 wkctx = repo[None] |
|
203 wparents = wkctx.parents() |
|
204 if len(wparents) != 1: |
|
205 raise util.Abort('merge in progress') |
|
206 |
|
207 children = [ctx for ctx in wparents[0].children() if not ctx.obsolete()] |
|
208 displayer = cmdutil.show_changeset(ui, repo, {'template': shorttemplate}) |
|
209 if not children: |
|
210 ui.warn(_('No non-obsolete children\n')) |
|
211 return 1 |
|
212 if len(children) == 1: |
|
213 c = children[0] |
|
214 hg.update(repo, c.rev()) |
|
215 displayer.show(c) |
|
216 return 0 |
|
217 else: |
|
218 for c in children: |
|
219 displayer.show(c) |
|
220 ui.warn(_('Multiple non-obsolete children, explicitly update to one\n')) |
|
221 return 1 |
192 |
222 |
193 |
223 |
194 @command('^kill', |
224 @command('^kill', |
195 [], |
225 [], |
196 '<revs>') |
226 '<revs>') |