Add descriptions to the plugins
[yap.git] / plugins / backup.py
blob621592be7d7de786bd5bb15bea8f9bb53b7cbd66
2 from yap import YapPlugin, YapError
3 import os
5 class BackupPlugin(YapPlugin):
6 "Save a backup of files before reverting them"
7 def __init__(self, yap):
8 self.yap = yap
10 def pre_revert(self, args, flags):
11 files = set(args)
12 changed = set(self.yap._get_staged_files() + self.yap._get_unstaged_files())
13 if '-a' in flags:
14 x = changed
15 else:
16 x = files.intersection(changed)
18 for f in x:
19 os.system("cp %s %s~" % (f, f))