[PATCH] rebase: allow pull --rebase --update

Stefano Tortarolo stefano.tortarolo at gmail.com
Sat Jan 17 05:34:32 CST 2009


# HG changeset patch
# User Stefano Tortarolo <stefano.tortarolo at gmail.com>
# Date 1232190634 -3600
# Node ID 7ad65f570cd8faf43e2951ef8bbd66c95e847f9c
# Parent  f7256cd9beffe9efd85957368781a88171ed9977
rebase: allow pull --rebase --update

diff -r f7256cd9beff -r 7ad65f570cd8 hgext/rebase.py
--- a/hgext/rebase.py	Thu Jan 15 11:41:59 2009 +0100
+++ b/hgext/rebase.py	Sat Jan 17 12:10:34 2009 +0100
@@ -399,8 +399,10 @@
 def pullrebase(orig, ui, repo, *args, **opts):
     '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'))
+        update = opts.get('update')
+        if update:
+            # this update request must be handled by rebase, not pull
+            del opts['update']
 
         cmdutil.bail_if_changed(repo)
         revsprepull = len(repo)
@@ -408,6 +410,12 @@
         revspostpull = len(repo)
         if revspostpull > revsprepull:
             rebase(ui, repo, **opts)
+            if update:
+                # if there was nothing to rebase we must force an update
+                branch = repo[None].branch()
+                dest = repo[branch].rev()
+                if dest != repo['.'].rev():
+                    merge.update(repo, dest, False, False, False)
     else:
         orig(ui, repo, *args, **opts)
 
diff -r f7256cd9beff -r 7ad65f570cd8 tests/test-rebase-pull
--- a/tests/test-rebase-pull	Thu Jan 15 11:41:59 2009 +0100
+++ b/tests/test-rebase-pull	Sat Jan 17 12:10:34 2009 +0100
@@ -25,6 +25,10 @@
 
 cd ..
 hg clone a b
+# These are needed to test pull --rebase and --rebase --update
+hg clone a c
+hg clone a d
+
 cd b
 addcommit "L1" 2
 
@@ -44,7 +48,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 "% Invoke pull --rebase with --update and nothing to rebase"
+cd ../d
+hg pull --rebase --update 2>&1 | sed 's/\(pulling from \).*/\1/'
+hg glog --template '{rev}\n' -l 1
 
 exit 0
diff -r f7256cd9beff -r 7ad65f570cd8 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	Sat Jan 17 12:10:34 2009 +0100
@@ -1,3 +1,7 @@
+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
 updating working directory
 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
 
@@ -30,5 +34,26 @@
 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
+o  2
+|
+
+% Invoke pull --rebase with --update 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
+|


More information about the Mercurial-devel mailing list