Mercurial > hg-stable
comparison hgext/rebase.py @ 28118:0e3835c7e1cf
rebase: perform update through the 'update' command
The update logic have grow more and more complicated over time (eg bookmark
movement, new destination logic, warning on other head, etc). The rebase
extension was reimplementing its own basic version of update to be used by 'hg
pull --rebase'. We remove the custom code and use a combination of higher level
functions.
A test is added to check that the update is properly warning about other branch
heads.
author | Pierre-Yves David <pierre-yves.david@fb.com> |
---|---|
date | Sun, 14 Feb 2016 00:45:17 +0000 |
parents | 41a0fb2b4bbc |
children | 6025ddb4e649 |
comparison
equal
deleted
inserted
replaced
28117:41a0fb2b4bbc | 28118:0e3835c7e1cf |
---|---|
14 https://mercurial-scm.org/wiki/RebaseExtension | 14 https://mercurial-scm.org/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, revset | 19 from mercurial import copies, destutil, 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 |
1143 if opts.get('update'): | 1143 if opts.get('update'): |
1144 del opts['update'] | 1144 del opts['update'] |
1145 ui.debug('--update and --rebase are not compatible, ignoring ' | 1145 ui.debug('--update and --rebase are not compatible, ignoring ' |
1146 'the update flag\n') | 1146 'the update flag\n') |
1147 | 1147 |
1148 movemarkfrom = repo['.'].node() | |
1149 revsprepull = len(repo) | 1148 revsprepull = len(repo) |
1150 origpostincoming = commands.postincoming | 1149 origpostincoming = commands.postincoming |
1151 def _dummy(*args, **kwargs): | 1150 def _dummy(*args, **kwargs): |
1152 pass | 1151 pass |
1153 commands.postincoming = _dummy | 1152 commands.postincoming = _dummy |
1164 # positional argument from pull conflicts with rebase's own | 1163 # positional argument from pull conflicts with rebase's own |
1165 # --source. | 1164 # --source. |
1166 if 'source' in opts: | 1165 if 'source' in opts: |
1167 del opts['source'] | 1166 del opts['source'] |
1168 if rebase(ui, repo, **opts) == _nothingtorebase(): | 1167 if rebase(ui, repo, **opts) == _nothingtorebase(): |
1169 branch = repo[None].branch() | 1168 rev, _a, _b = destutil.destupdate(repo) |
1170 dest = repo[branch].rev() | 1169 if rev != repo['.'].rev(): # we could update |
1171 if dest != repo['.'].rev(): | 1170 # not passing argument to get the bare update behavior |
1172 # there was nothing to rebase we force an update | 1171 # with warning and trumpets |
1173 hg.update(repo, dest) | 1172 commands.update(ui, repo) |
1174 if bookmarks.update(repo, [movemarkfrom], | |
1175 repo['.'].node()): | |
1176 ui.status(_("updating bookmark %s\n") | |
1177 % repo._activebookmark) | |
1178 finally: | 1173 finally: |
1179 release(lock, wlock) | 1174 release(lock, wlock) |
1180 else: | 1175 else: |
1181 if opts.get('tool'): | 1176 if opts.get('tool'): |
1182 raise error.Abort(_('--tool can only be used with --rebase')) | 1177 raise error.Abort(_('--tool can only be used with --rebase')) |