[PATCH 6 of 6] rebase: use hg.updatetotally instead of commands.update for efficiency

FUJIWARA Katsunori foozy at lares.dti.ne.jp
Fri Mar 11 14:41:11 EST 2016


# HG changeset patch
# User FUJIWARA Katsunori <foozy at lares.dti.ne.jp>
# Date 1457724942 -32400
#      Sat Mar 12 04:35:42 2016 +0900
# Node ID 1b9adcf57c8eba8c3bee50a8de8b11ef0502b28f
# Parent  4ec341fd8f85ca07dc6f99d82c155e9d559be390
rebase: use hg.updatetotally instead of commands.update for efficiency

Using hg.updatetotally() instead of commands.update() is efficient in
the point of below:

  - meaningless checking options in commands.update() is omitted

  - calculation of update destination by destutil.destupdate() occurs
    only once

diff --git a/hgext/rebase.py b/hgext/rebase.py
--- a/hgext/rebase.py
+++ b/hgext/rebase.py
@@ -1213,14 +1213,13 @@ def pullrebase(orig, ui, repo, *args, **
                     rebase(ui, repo, **opts)
                 except error.NoMergeDestAbort:
                     # we can maybe update instead
-                    rev, _a, _b = destutil.destupdate(repo)
-                    if rev == repo['.'].rev():
-                        ui.status(_('nothing to rebase\n'))
-                    else:
+                    def skipupdate(destrev):
+                        if destrev == repo['.'].rev():
+                            ui.status(_('nothing to rebase\n'))
+                            return True
                         ui.status(_('nothing to rebase - updating instead\n'))
-                        # not passing argument to get the bare update behavior
-                        # with warning and trumpets
-                        commands.update(ui, repo)
+                    hg.updatetotally(ui, repo, None, None,
+                                     skipupdate=skipupdate)
         finally:
             release(lock, wlock)
     else:


More information about the Mercurial-devel mailing list