def fl_revert(args): """revert - revert <file> back to its most recent saved version usage: fl revert <file> <file> <file> ... For each file listed in the command line, look for 'save'd version and bring it back. The current file is renamed <file>.new. """ p = OptionParser() p.add_option('-n', '--noexec', default=True, action='store_false', dest='xable', help='just do a dry run') (o, a) = p.parse_args(args) for f in a: dir = os.path.dirname(f) if dir == '': dir = '.' counterpath = most_recent_prefix_match(dir, os.path.basename(f)) tpbtools.run('mv %s %s.new' % (f, f), o.xable) tpbtools.run('mv %s %s' % (counterpath, f), o.xable)
def fl_diff(args): """diff - compare file to its most recently 'saved' version usage: fl diff file1 file2 file3 ... """ p = OptionParser() p.add_option('-n', '--noexec', default=True, action='store_false', dest='xable', help='just do a dry run') (o, a) = p.parse_args(args) for filename in a: dirname = os.path.dirname(filename) if dirname == '': dirname = '.' counterpath = most_recent_prefix_match(dirname, os.path.basename(filename)) cmd = 'diff %s %s' % (counterpath, filename) print cmd sys.stdout.flush() tpbtools.run(cmd, o.xable)