[PATCH] rebase: invalidate caches before stripping (issue1951)

Stefano Tortarolo stefano.tortarolo at gmail.com
Thu Feb 11 04:35:48 CST 2010


# HG changeset patch
# User Stefano Tortarolo <stefano.tortarolo at gmail.com>
# Date 1265884017 -3600
# Node ID ce7e84d20a5430e316544e70fd504d6945ce99cb
# Parent  1a8df80dfddefe8b45f61529bbe2f2615786a77b
rebase: invalidate caches before stripping (issue1951)

In issue1951 rebase tries to strip the old revisions using an outdated
branchcache. This patch simply invalidates the repo's caches before
invoking strip.

diff --git a/hgext/rebase.py b/hgext/rebase.py
--- a/hgext/rebase.py
+++ b/hgext/rebase.py
@@ -172,6 +172,8 @@
                     ui.warn(_("warning: new changesets detected on source branch, "
                                                             "not stripping\n"))
                 else:
+                    # Invalidate repo's caches before stripping
+                    repo.invalidate()
                     repair.strip(ui, repo, repo[min(rebased)].node(), "strip")
 
         clearstatus(repo)
diff --git a/tests/test-rebase-cache b/tests/test-rebase-cache
new file mode 100755
--- /dev/null
+++ b/tests/test-rebase-cache
@@ -0,0 +1,37 @@
+#!/bin/sh
+
+hg init repo
+cd repo
+
+echo "a" > a
+echo "b" > b
+hg commit -d '1 0' -A -m 'A'
+
+hg branch branch1
+hg commit -d '2 0' -m 'Branch1'
+
+echo "a1" > a
+hg commit -d '3 0' -m 'A1'
+
+hg branch branch2
+hg commit -d '4 0' -m 'Branch2'
+
+echo "a2" > a
+hg commit -d '5 0' -m 'A2'
+
+hg update default
+
+hg branch branch3
+hg commit -d '6 0' -m 'Branch3'
+
+echo "b1" > b
+hg commit -d '7 0' -m 'B1'
+
+hg --config extensions.hgext.graphlog= glog --template '{rev}:{node|short} {desc} branch: {branches}\n'
+
+echo
+echo '% Rebase branch2 (3) onto branch3 (6)'
+hg --config extensions.hgext.rebase= rebase -s 3 2>&1 | sed 's/\(saving bundle to \).*/\1/'
+
+echo
+hg --config extensions.hgext.graphlog= glog --template '{rev}:{node|short} {desc} branch: {branches}\n'
diff --git a/tests/test-rebase-cache.out b/tests/test-rebase-cache.out
new file mode 100644
--- /dev/null
+++ b/tests/test-rebase-cache.out
@@ -0,0 +1,45 @@
+adding a
+adding b
+marked working directory as branch branch1
+marked working directory as branch branch2
+1 files updated, 0 files merged, 0 files removed, 0 files unresolved
+marked working directory as branch branch3
+created new head
+@  6:1135ac1fc347 B1 branch: branch3
+|
+o  5:47042d02252f Branch3 branch: branch3
+|
+| o  4:77438a15bb7d A2 branch: branch2
+| |
+| o  3:89161532d768 Branch2 branch: branch2
+| |
+| o  2:2ebbca030aa3 A1 branch: branch1
+| |
+| o  1:6f2597196b18 Branch1 branch: branch1
+|/
+o  0:c064445f9492 A branch:
+
+
+% Rebase branch2 (3) onto branch3 (6)
+saving bundle to 
+adding branch
+adding changesets
+adding manifests
+adding file changes
+added 4 changesets with 2 changes to 2 files
+rebase completed
+
+@  6:15989d05165e A2 branch: branch3
+|
+o    5:82c21c9b4669 Branch2 branch: branch3
+|\
+| o  4:1135ac1fc347 B1 branch: branch3
+| |
+| o  3:47042d02252f Branch3 branch: branch3
+| |
+o |  2:2ebbca030aa3 A1 branch: branch1
+| |
+o |  1:6f2597196b18 Branch1 branch: branch1
+|/
+o  0:c064445f9492 A branch:
+


More information about the Mercurial-devel mailing list