aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJuergen Wieferink <wieferink@fhi-berlin.mpg.de>2010-10-22 16:44:13 +0100
committerCatalin Marinas <catalin.marinas@gmail.com>2010-10-22 16:44:13 +0100
commit2d0f10fb98274e3b3827bf227e42e420f878f1d1 (patch)
treeeb288aede63bb73eedcaa5d6a4dbe57dabaec417
parent3f47bf3a0d06007bd9ee2fa2c81bef8761b328a4 (diff)
downloadstgit-2d0f10fb98274e3b3827bf227e42e420f878f1d1.tar.gz
Fix stg repair for hidden patches
Signed-off-by: Juergen Wieferink <wieferink@fhi-berlin.mpg.de> Signed-off-by: Catalin Marinas <catalin.marinas@gmail.com>
-rw-r--r--stgit/commands/repair.py19
-rw-r--r--stgit/stack.py3
-rwxr-xr-xt/t1304-repair-hidden.sh43
3 files changed, 60 insertions, 5 deletions
diff --git a/stgit/commands/repair.py b/stgit/commands/repair.py
index 5804a12..2e22150 100644
--- a/stgit/commands/repair.py
+++ b/stgit/commands/repair.py
@@ -121,6 +121,7 @@ def func(parser, options, args):
orig_applied = crt_series.get_applied()
orig_unapplied = crt_series.get_unapplied()
+ orig_hidden = crt_series.get_hidden()
if crt_series.get_protected():
raise CmdException(
@@ -184,22 +185,29 @@ def func(parser, options, args):
names.add(name)
out.done()
+ # Figure out hidden
+ orig_patches = orig_applied + orig_unapplied + orig_hidden
+ orig_applied_name_set = set(orig_applied)
+ orig_unapplied_name_set = set(orig_unapplied)
+ orig_hidden_name_set = set(orig_hidden)
+ orig_patches_name_set = set(orig_patches)
+ hidden = [p for p in patches if p.patch in orig_hidden_name_set]
+
# Write the applied/unapplied files.
out.start('Checking patch appliedness')
- unapplied = patches - set(applied)
+ unapplied = patches - set(applied) - set(hidden)
applied_name_set = set(p.patch for p in applied)
unapplied_name_set = set(p.patch for p in unapplied)
+ hidden_name_set = set(p.patch for p in hidden)
patches_name_set = set(p.patch for p in patches)
- orig_patches = orig_applied + orig_unapplied
- orig_applied_name_set = set(orig_applied)
- orig_unapplied_name_set = set(orig_unapplied)
- orig_patches_name_set = set(orig_patches)
for name in orig_patches_name_set - patches_name_set:
out.info('%s is gone' % name)
for name in applied_name_set - orig_applied_name_set:
out.info('%s is now applied' % name)
for name in unapplied_name_set - orig_unapplied_name_set:
out.info('%s is now unapplied' % name)
+ for name in hidden_name_set - orig_hidden_name_set:
+ out.info('%s is now hidden' % name)
orig_order = dict(zip(orig_patches, xrange(len(orig_patches))))
def patchname_cmp(p1, p2):
i1 = orig_order.get(p1, len(orig_order))
@@ -207,4 +215,5 @@ def func(parser, options, args):
return cmp((i1, p1), (i2, p2))
crt_series.set_applied(p.patch for p in applied)
crt_series.set_unapplied(sorted(unapplied_name_set, cmp = patchname_cmp))
+ crt_series.set_hidden(sorted(hidden_name_set, cmp = patchname_cmp))
out.done()
diff --git a/stgit/stack.py b/stgit/stack.py
index 93647f2..f166aea 100644
--- a/stgit/stack.py
+++ b/stgit/stack.py
@@ -438,6 +438,9 @@ class Series(PatchSet):
return []
return read_strings(self.__hidden_file)
+ def set_hidden(self, hidden):
+ write_strings(self.__hidden_file, hidden)
+
def get_base(self):
# Return the parent of the bottommost patch, if there is one.
if os.path.isfile(self.__applied_file):
diff --git a/t/t1304-repair-hidden.sh b/t/t1304-repair-hidden.sh
new file mode 100755
index 0000000..ffbcef8
--- /dev/null
+++ b/t/t1304-repair-hidden.sh
@@ -0,0 +1,43 @@
+#!/bin/sh
+#
+# Copyright (c) 2010 Juergen Wieferink
+#
+
+test_description='Test repair with hidden patches
+
+'
+
+. ./test-lib.sh
+
+test_expect_success \
+ 'Initialize the StGIT repository' \
+ 'stg init &&
+ stg new A -m "a" && echo A >a.txt && stg add a.txt && stg refresh &&
+ stg new B -m "b" && echo B >b.txt && stg add b.txt && stg refresh &&
+ stg new C -m "c" && echo C >c.txt && stg add c.txt && stg refresh &&
+ stg new D -m "d" && echo D >d.txt && stg add d.txt && stg refresh &&
+ stg pop && stg hide D &&
+ stg pop &&
+ test "$(echo $(stg series --applied --noprefix))" = "A B" &&
+ test "$(echo $(stg series --unapplied --noprefix))" = "C" &&
+ test "$(echo $(stg series --hidden --noprefix))" = "D"
+ '
+
+test_expect_success \
+ 'Repair and check that nothing has changed' \
+ 'stg repair &&
+ test "$(echo $(stg series --applied --noprefix))" = "A B" &&
+ test "$(echo $(stg series --unapplied --noprefix))" = "C" &&
+ test "$(echo $(stg series --hidden --noprefix))" = "D"
+ '
+
+test_expect_success \
+ 'Nontrivial repair' \
+ 'echo Z >z.txt && git add z.txt && git commit -m z &&
+ stg repair &&
+ test "$(echo $(stg series --applied --noprefix))" = "A B z" &&
+ test "$(echo $(stg series --unapplied --noprefix))" = "C" &&
+ test "$(echo $(stg series --hidden --noprefix))" = "D"
+ '
+
+test_done