[PATCH] rebase: pull --rebase updates if there is nothing to rebase

Stefano Tortarolo stefano.tortarolo at gmail.com
Sun Jan 18 14:34:13 CST 2009


# HG changeset patch
# User Stefano Tortarolo <stefano.tortarolo at gmail.com>
# Date 1232305191 -3600
# Node ID b6476dabf44524e9568b41e1c77bee62df33a300
# Parent  f7256cd9beffe9efd85957368781a88171ed9977
rebase: pull --rebase updates if there is nothing to rebase

diff -r f7256cd9beff -r b6476dabf445 hgext/rebase.py
--- a/hgext/rebase.py	Thu Jan 15 11:41:59 2009 +0100
+++ b/hgext/rebase.py	Sun Jan 18 19:59:51 2009 +0100
@@ -400,7 +400,9 @@
     'Call rebase after pull if the latter has been invoked with --rebase'
     if opts.get('rebase'):
         if opts.get('update'):
-            raise util.Abort(_('--update and --rebase are not compatible'))
+            del opts.get['update']
+            ui.debug(_('--update and --rebase are not compatible, ignoring '
+                                        'the update flag\n'))
 
         cmdutil.bail_if_changed(repo)
         revsprepull = len(repo)
@@ -408,6 +410,11 @@
         revspostpull = len(repo)
         if revspostpull > revsprepull:
             rebase(ui, repo, **opts)
+            branch = repo[None].branch()
+            dest = repo[branch].rev()
+            if dest != repo['.'].rev():
+                # there was nothing to rebase we force an update
+                merge.update(repo, dest, False, False, False)
     else:
         orig(ui, repo, *args, **opts)
 
diff -r f7256cd9beff -r b6476dabf445 tests/test-rebase-pull
--- a/tests/test-rebase-pull	Thu Jan 15 11:41:59 2009 +0100
+++ b/tests/test-rebase-pull	Sun Jan 18 19:59:51 2009 +0100
@@ -25,6 +25,9 @@
 
 cd ..
 hg clone a b
+# This is needed to test pull --rebase
+hg clone a c
+
 cd b
 addcommit "L1" 2
 
@@ -44,7 +47,15 @@
 hg pull --rebase 2>&1 | sed 's/\(pulling from \).*/\1/'
 
 echo
-echo "% Invoke pull --rebase with --update"
-hg pull --rebase --update
+echo "% Invoke pull --rebase and nothing to rebase"
+cd ../c
+hg pull --rebase 2>&1 | sed 's/\(pulling from \).*/\1/'
+hg glog --template '{rev}\n' -l 1
+
+echo
+echo "% pull --rebase doesn't update if nothing has been pulled"
+hg up 1
+hg pull --rebase 2>&1 | sed 's/\(pulling from \).*/\1/'
+hg glog --template '{rev}\n' -l 1
 
 exit 0
diff -r f7256cd9beff -r b6476dabf445 tests/test-rebase-pull.out
--- a/tests/test-rebase-pull.out	Thu Jan 15 11:41:59 2009 +0100
+++ b/tests/test-rebase-pull.out	Sun Jan 18 19:59:51 2009 +0100
@@ -1,3 +1,5 @@
+updating working directory
+2 files updated, 0 files merged, 0 files removed, 0 files unresolved
 updating working directory
 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
 
@@ -30,5 +32,22 @@
 searching for changes
 no changes found
 
-% Invoke pull --rebase with --update
-abort: --update and --rebase are not compatible
+% Invoke pull --rebase and nothing to rebase
+pulling from 
+searching for changes
+adding changesets
+adding manifests
+adding file changes
+added 1 changesets with 1 changes to 1 files
+(run 'hg update' to get a working copy)
+nothing to rebase
+@  2
+|
+
+% pull --rebase doesn't update if nothing has been pulled
+0 files updated, 0 files merged, 1 files removed, 0 files unresolved
+pulling from 
+searching for changes
+no changes found
+o  2
+|


More information about the Mercurial-devel mailing list