Handle being on a detached HEAD better
[yap.git] / plugins / backup.py
blobfc4dc9d9be38dc132e199aa410bf52c0b1c1891a
2 from yap import YapPlugin, YapError
3 import os
5 class BackupPlugin(YapPlugin):
6 def __init__(self, yap):
7 self.yap = yap
9 def pre_revert(self, *args, **flags):
10 files = set(args)
11 changed = set(self.yap._get_staged_files() + self.yap._get_unstaged_files())
12 if '-a' in flags:
13 x = changed
14 else:
15 x = files.intersection(changed)
17 for f in x:
18 os.system("cp %s %s~" % (f, f))