Port plugins to the new plugin API
[yap.git] / plugins / backup.py
blob0031a1712b919b593214e774a855819dea2e63d3
2 from yap.yap import YapCore, YapError
3 import os
5 class BackupPlugin(YapCore):
6 "Save a backup of files before reverting them"
8 def cmd_revert(self, *args, **flags):
9 files = set(args)
10 changed = set(self._get_staged_files() + self._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))
19 super(BackupPlugin, self).cmd_revert(*args, **flags)