Mercurial > hg
comparison hgext/rebase.py @ 26301:3f8c5c284c86
rebase: move destination computation in a revset
This is the first step toward making the "default destination" logic more clear
and unified. The revset is private because I'm happy to delay the bikeshedding until
after the clean up happened.
author | Pierre-Yves David <pierre-yves.david@fb.com> |
---|---|
date | Thu, 17 Sep 2015 10:59:52 -0700 |
parents | 927c0d84e09f |
children | 92409f8dff5d |
comparison
equal
deleted
inserted
replaced
26300:f946c1260035 | 26301:3f8c5c284c86 |
---|---|
14 http://mercurial.selenic.com/wiki/RebaseExtension | 14 http://mercurial.selenic.com/wiki/RebaseExtension |
15 ''' | 15 ''' |
16 | 16 |
17 from mercurial import hg, util, repair, merge, cmdutil, commands, bookmarks | 17 from mercurial import hg, util, repair, merge, cmdutil, commands, bookmarks |
18 from mercurial import extensions, patch, scmutil, phases, obsolete, error | 18 from mercurial import extensions, patch, scmutil, phases, obsolete, error |
19 from mercurial import copies, repoview | 19 from mercurial import copies, repoview, revset |
20 from mercurial.commands import templateopts | 20 from mercurial.commands import templateopts |
21 from mercurial.node import nullrev, nullid, hex, short | 21 from mercurial.node import nullrev, nullid, hex, short |
22 from mercurial.lock import release | 22 from mercurial.lock import release |
23 from mercurial.i18n import _ | 23 from mercurial.i18n import _ |
24 import os, errno | 24 import os, errno |
51 """ | 51 """ |
52 def extrafn(ctx, extra): | 52 def extrafn(ctx, extra): |
53 for c in copiers: | 53 for c in copiers: |
54 c(ctx, extra) | 54 c(ctx, extra) |
55 return extrafn | 55 return extrafn |
56 | |
57 def _rebasedefaultdest(repo, subset, x): | |
58 # ``_rebasedefaultdest()`` | |
59 | |
60 # default destination for rebase. | |
61 # # XXX: Currently private because I expect the signature to change. | |
62 # # XXX: - taking rev as arguments, | |
63 # # XXX: - bailing out in case of ambiguity vs returning all data. | |
64 # # XXX: - probably merging with the merge destination. | |
65 # i18n: "_rebasedefaultdest" is a keyword | |
66 revset.getargs(x, 0, 0, _("_rebasedefaultdest takes no arguments")) | |
67 # Destination defaults to the latest revision in the | |
68 # current branch | |
69 branch = repo[None].branch() | |
70 return subset & revset.baseset([repo[branch].rev()]) | |
56 | 71 |
57 @command('rebase', | 72 @command('rebase', |
58 [('s', 'source', '', | 73 [('s', 'source', '', |
59 _('rebase the specified changeset and descendants'), _('REV')), | 74 _('rebase the specified changeset and descendants'), _('REV')), |
60 ('b', 'base', '', | 75 ('b', 'base', '', |
250 | 265 |
251 cmdutil.checkunfinished(repo) | 266 cmdutil.checkunfinished(repo) |
252 cmdutil.bailifchanged(repo) | 267 cmdutil.bailifchanged(repo) |
253 | 268 |
254 if not destf: | 269 if not destf: |
255 # Destination defaults to the latest revision in the | 270 destf = '_rebasedefaultdest()' |
256 # current branch | 271 dest = scmutil.revsingle(repo, destf) |
257 branch = repo[None].branch() | |
258 dest = repo[branch] | |
259 else: | |
260 dest = scmutil.revsingle(repo, destf) | |
261 | 272 |
262 if revf: | 273 if revf: |
263 rebaseset = scmutil.revrange(repo, revf) | 274 rebaseset = scmutil.revrange(repo, revf) |
264 if not rebaseset: | 275 if not rebaseset: |
265 ui.status(_('empty "rev" revision set - ' | 276 ui.status(_('empty "rev" revision set - ' |
1124 cmdutil.unfinishedstates.append( | 1135 cmdutil.unfinishedstates.append( |
1125 ['rebasestate', False, False, _('rebase in progress'), | 1136 ['rebasestate', False, False, _('rebase in progress'), |
1126 _("use 'hg rebase --continue' or 'hg rebase --abort'")]) | 1137 _("use 'hg rebase --continue' or 'hg rebase --abort'")]) |
1127 # ensure rebased rev are not hidden | 1138 # ensure rebased rev are not hidden |
1128 extensions.wrapfunction(repoview, '_getdynamicblockers', _rebasedvisible) | 1139 extensions.wrapfunction(repoview, '_getdynamicblockers', _rebasedvisible) |
1140 revset.symbols['_rebasedefaultdest'] = _rebasedefaultdest |