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(
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))
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()
--- /dev/null
+#!/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