diff 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
line wrap: on
line diff
--- a/hgext/rebase.py	Sat Feb 13 16:59:32 2016 +0000
+++ b/hgext/rebase.py	Sun Feb 14 00:45:17 2016 +0000
@@ -16,7 +16,7 @@
 
 from mercurial import hg, util, repair, merge, cmdutil, commands, bookmarks
 from mercurial import extensions, patch, scmutil, phases, obsolete, error
-from mercurial import copies, repoview, revset
+from mercurial import copies, destutil, repoview, revset
 from mercurial.commands import templateopts
 from mercurial.node import nullrev, nullid, hex, short
 from mercurial.lock import release
@@ -1145,7 +1145,6 @@
                 ui.debug('--update and --rebase are not compatible, ignoring '
                          'the update flag\n')
 
-            movemarkfrom = repo['.'].node()
             revsprepull = len(repo)
             origpostincoming = commands.postincoming
             def _dummy(*args, **kwargs):
@@ -1166,15 +1165,11 @@
                 if 'source' in opts:
                     del opts['source']
                 if rebase(ui, repo, **opts) == _nothingtorebase():
-                    branch = repo[None].branch()
-                    dest = repo[branch].rev()
-                    if dest != repo['.'].rev():
-                        # there was nothing to rebase we force an update
-                        hg.update(repo, dest)
-                        if bookmarks.update(repo, [movemarkfrom],
-                                            repo['.'].node()):
-                            ui.status(_("updating bookmark %s\n")
-                                      % repo._activebookmark)
+                    rev, _a, _b = destutil.destupdate(repo)
+                    if rev != repo['.'].rev(): # we could update
+                        # not passing argument to get the bare update behavior
+                        # with warning and trumpets
+                        commands.update(ui, repo)
         finally:
             release(lock, wlock)
     else: