diff --git a/hgext/rebase.py b/hgext/rebase.py --- a/hgext/rebase.py +++ b/hgext/rebase.py @@ -1165,15 +1165,16 @@ def pullrebase(orig, ui, repo, *args, ** # --source. if 'source' in opts: del opts['source'] - 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 - hg.update(repo, dest) - if bookmarks.update(repo, [movemarkfrom], repo['.'].node()): - ui.status(_("updating bookmark %s\n") - % repo._activebookmark) + 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) finally: release(lock, wlock) else: diff --git a/tests/test-rebase-pull.t b/tests/test-rebase-pull.t --- a/tests/test-rebase-pull.t +++ b/tests/test-rebase-pull.t @@ -209,3 +209,60 @@ pull --rebase works with bundle2 turned | o 0: 'C1' + +pull --rebase only update if there is nothing to rebase + + $ cd ../a + $ echo R5 > R5 + $ hg ci -Am R5 + adding R5 + $ hg tglog + @ 6: 'R5' + | + o 5: 'R4' + | + o 4: 'R3' + | + o 3: 'R2' + | + o 2: 'R1' + | + o 1: 'C2' + | + o 0: 'C1' + + $ cd ../c + $ echo L2 > L2 + $ hg ci -Am L2 + adding L2 + $ hg up 'desc(L1)' + 0 files updated, 0 files merged, 1 files removed, 0 files unresolved + $ hg pull --rebase + pulling from $TESTTMP/a (glob) + searching for changes + adding changesets + adding manifests + adding file changes + added 1 changesets with 1 changes to 1 files (+1 heads) + rebasing 6:0d0727eb7ce0 "L1" + rebasing 7:c1f58876e3bf "L2" + saved backup bundle to $TESTTMP/c/.hg/strip-backup/0d0727eb7ce0-ef61ccb2-backup.hg (glob) + $ hg tglog + o 8: 'L2' + | + @ 7: 'L1' + | + o 6: 'R5' + | + o 5: 'R4' + | + o 4: 'R3' + | + o 3: 'R2' + | + o 2: 'R1' + | + o 1: 'C2' + | + o 0: 'C1' +