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

Stefano Tortarolo stefano.tortarolo at gmail.com
Sun Feb 21 13:59:54 CST 2010


# HG changeset patch
# User Stefano Tortarolo <stefano.tortarolo at gmail.com>
# Date 1266782367 -3600
# Node ID af4dbc07632e5cbbc906dd7420ae96b057bdfad5
# Parent  261cc6b0f15c7e83dcff7dd7d5f3607c098c29bd
rebase: invalidate caches before stripping (issue1951)

diff --git a/hgext/rebase.py b/hgext/rebase.py
--- a/hgext/rebase.py
+++ b/hgext/rebase.py
@@ -172,6 +172,7 @@
                     ui.warn(_("warning: new changesets detected "
                               "on source branch, not stripping\n"))
                 else:
+                    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,104 @@
+#!/bin/sh
+
+createrepo() {
+    rm -rf repo
+    hg init repo
+    cd repo
+
+    echo "a" > a
+    hg commit -d '0 0' -A -m 'A'
+
+    hg branch branch1
+    hg commit -d '1 0' -m 'Branch1'
+
+    echo "b" > b
+    hg commit -A -d '2 0' -m 'B'
+
+    hg up 0
+    hg branch branch2
+    hg commit -d '3 0' -m 'Branch2'
+
+    echo "c" > C
+    hg commit -A -d '4 0' -m 'C'
+
+    hg up 2
+    hg branch -f branch2
+    echo "d" > d
+    hg commit -A -d '5 0' -m 'D'
+
+    echo "e" > e
+    hg commit -A -d '6 0' -m 'E'
+
+    hg update default
+
+    hg branch branch3
+    hg commit -d '7 0' -m 'Branch3'
+
+    echo "f" > f
+    hg commit -A -d '8 0' -m 'F'
+}
+
+echo
+createrepo > /dev/null 2>&1
+hg --config extensions.hgext.graphlog= glog --template '{rev}:{node|short} {desc} branch: {branches}\n'
+
+echo
+echo '% Branches'
+hg branches
+
+echo
+echo '% Heads'
+hg heads --template '{rev}:{node|short} {desc} branch: {branches}\n'
+
+echo
+echo '% Rebase part of branch2 (5-6) onto branch3 (8)'
+hg --config extensions.hgext.rebase= rebase --detach -s 5 -d 8 2>&1 | sed 's/\(saving bundle to \).*/\1/'
+
+echo
+echo '% Branches'
+hg branches
+
+echo
+echo '% Heads'
+hg heads --template '{rev}:{node|short} {desc} branch: {branches}\n'
+
+echo
+hg --config extensions.hgext.graphlog= glog --template '{rev}:{node|short} {desc} branch: {branches}\n'
+
+echo
+echo '% Rebase head of branch3 (8) onto branch2 (6)'
+createrepo > /dev/null 2>&1
+hg --config extensions.hgext.graphlog= glog --template '{rev}:{node|short} {desc} branch: {branches}\n'
+
+hg --config extensions.hgext.rebase= rebase --detach -s 8 -d 6 2>&1 | sed 's/\(saving bundle to \).*/\1/'
+
+echo
+echo '% Branches'
+hg branches
+
+echo
+echo '% Heads'
+hg heads --template '{rev}:{node|short} {desc} branch: {branches}\n'
+
+echo
+hg --config extensions.hgext.graphlog= glog --template '{rev}:{node|short} {desc} branch: {branches}\n'
+hg verify -q
+
+echo
+echo '% Rebase entire branch3 (7-8) onto branch2 (6)'
+createrepo > /dev/null 2>&1
+hg --config extensions.hgext.graphlog= glog --template '{rev}:{node|short} {desc} branch: {branches}\n'
+
+hg --config extensions.hgext.rebase= rebase --detach -s 7 -d 6 2>&1 | sed 's/\(saving bundle to \).*/\1/'
+
+echo
+echo '% Branches'
+hg branches
+
+echo
+echo '% Heads'
+hg heads --template '{rev}:{node|short} {desc} branch: {branches}\n'
+
+echo
+hg --config extensions.hgext.graphlog= glog --template '{rev}:{node|short} {desc} branch: {branches}\n'
+hg verify -q
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,186 @@
+
+@  8:c11d5b3e9c00 F branch: branch3
+|
+o  7:33c9da881988 Branch3 branch: branch3
+|
+| o  6:0e4064ab11a3 E branch: branch2
+| |
+| o  5:5ac035cb5d8f D branch: branch2
+| |
+| | o  4:8e66061486ee C branch: branch2
+| | |
++---o  3:99567862abbe Branch2 branch: branch2
+| |
+| o  2:65a26a4d12f6 B branch: branch1
+| |
+| o  1:0f3f3010ee16 Branch1 branch: branch1
+|/
+o  0:1994f17a630e A branch:
+
+
+% Branches
+branch3                        8:c11d5b3e9c00
+branch2                        6:0e4064ab11a3
+branch1                        2:65a26a4d12f6 (inactive)
+default                        0:1994f17a630e (inactive)
+
+% Heads
+8:c11d5b3e9c00 F branch: branch3
+6:0e4064ab11a3 E branch: branch2
+4:8e66061486ee C branch: branch2
+2:65a26a4d12f6 B branch: branch1
+0:1994f17a630e A branch: 
+
+% Rebase part of branch2 (5-6) onto branch3 (8)
+saving bundle to 
+adding branch
+adding changesets
+adding manifests
+adding file changes
+added 4 changesets with 3 changes to 3 files (+1 heads)
+rebase completed
+
+% Branches
+branch3                        8:c9bfa9beb84e
+branch2                        4:8e66061486ee
+branch1                        2:65a26a4d12f6
+default                        0:1994f17a630e (inactive)
+
+% Heads
+8:c9bfa9beb84e E branch: branch3
+4:8e66061486ee C branch: branch2
+2:65a26a4d12f6 B branch: branch1
+0:1994f17a630e A branch: 
+
+@  8:c9bfa9beb84e E branch: branch3
+|
+o  7:bf9037384081 D branch: branch3
+|
+o  6:c11d5b3e9c00 F branch: branch3
+|
+o  5:33c9da881988 Branch3 branch: branch3
+|
+| o  4:8e66061486ee C branch: branch2
+| |
+| o  3:99567862abbe Branch2 branch: branch2
+|/
+| o  2:65a26a4d12f6 B branch: branch1
+| |
+| o  1:0f3f3010ee16 Branch1 branch: branch1
+|/
+o  0:1994f17a630e A branch:
+
+
+% Rebase head of branch3 (8) onto branch2 (6)
+@  8:c11d5b3e9c00 F branch: branch3
+|
+o  7:33c9da881988 Branch3 branch: branch3
+|
+| o  6:0e4064ab11a3 E branch: branch2
+| |
+| o  5:5ac035cb5d8f D branch: branch2
+| |
+| | o  4:8e66061486ee C branch: branch2
+| | |
++---o  3:99567862abbe Branch2 branch: branch2
+| |
+| o  2:65a26a4d12f6 B branch: branch1
+| |
+| o  1:0f3f3010ee16 Branch1 branch: branch1
+|/
+o  0:1994f17a630e A branch:
+
+saving bundle to 
+adding branch
+adding changesets
+adding manifests
+adding file changes
+added 1 changesets with 1 changes to 1 files
+rebase completed
+
+% Branches
+branch2                        8:b44d3024f247
+branch3                        7:33c9da881988
+branch1                        2:65a26a4d12f6 (inactive)
+default                        0:1994f17a630e (inactive)
+
+% Heads
+8:b44d3024f247 F branch: branch2
+7:33c9da881988 Branch3 branch: branch3
+4:8e66061486ee C branch: branch2
+2:65a26a4d12f6 B branch: branch1
+0:1994f17a630e A branch: 
+
+@  8:b44d3024f247 F branch: branch2
+|
+| o  7:33c9da881988 Branch3 branch: branch3
+| |
+o |  6:0e4064ab11a3 E branch: branch2
+| |
+o |  5:5ac035cb5d8f D branch: branch2
+| |
+| | o  4:8e66061486ee C branch: branch2
+| | |
+| | o  3:99567862abbe Branch2 branch: branch2
+| |/
+o |  2:65a26a4d12f6 B branch: branch1
+| |
+o |  1:0f3f3010ee16 Branch1 branch: branch1
+|/
+o  0:1994f17a630e A branch:
+
+
+% Rebase entire branch3 (7-8) onto branch2 (6)
+@  8:c11d5b3e9c00 F branch: branch3
+|
+o  7:33c9da881988 Branch3 branch: branch3
+|
+| o  6:0e4064ab11a3 E branch: branch2
+| |
+| o  5:5ac035cb5d8f D branch: branch2
+| |
+| | o  4:8e66061486ee C branch: branch2
+| | |
++---o  3:99567862abbe Branch2 branch: branch2
+| |
+| o  2:65a26a4d12f6 B branch: branch1
+| |
+| o  1:0f3f3010ee16 Branch1 branch: branch1
+|/
+o  0:1994f17a630e A branch:
+
+saving bundle to 
+adding branch
+adding changesets
+adding manifests
+adding file changes
+added 1 changesets with 1 changes to 1 files
+rebase completed
+
+% Branches
+branch2                        7:b44d3024f247
+branch1                        2:65a26a4d12f6 (inactive)
+default                        0:1994f17a630e (inactive)
+
+% Heads
+7:b44d3024f247 F branch: branch2
+4:8e66061486ee C branch: branch2
+2:65a26a4d12f6 B branch: branch1
+0:1994f17a630e A branch: 
+
+@  7:b44d3024f247 F branch: branch2
+|
+o  6:0e4064ab11a3 E branch: branch2
+|
+o  5:5ac035cb5d8f D branch: branch2
+|
+| o  4:8e66061486ee C branch: branch2
+| |
+| o  3:99567862abbe Branch2 branch: branch2
+| |
+o |  2:65a26a4d12f6 B branch: branch1
+| |
+o |  1:0f3f3010ee16 Branch1 branch: branch1
+|/
+o  0:1994f17a630e A branch:
+


More information about the Mercurial-devel mailing list