X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~mdw/git/rsync-backup/blobdiff_plain/9653f45d4e6e3009f86f912c7bee4441e9ae2b06..HEAD:/fshash.in diff --git a/fshash.in b/fshash.in index 525b0f0..dcfd229 100644 --- a/fshash.in +++ b/fshash.in @@ -449,6 +449,7 @@ class Reporter (object): suffix = '\0%d' % seq seq += 1 me._inomap[inoidx] = vino + if OPTS.compat >= 2: me._vinomap[vino] = inoidx if h: info = h else: info = '[%-*s]' % (2*me._hsz - 2, fmt.info()) print '%s %8s %6s %-12s %-20s %20s %s' % ( @@ -586,33 +587,39 @@ for short, long, props in [ 'help': 'read files to report in the given FORMAT' }), ('-u', '--udiff', { 'action': 'store_true', 'dest': 'udiff', 'help': 'read diff from stdin, clear cache entries' }), + ('-C', '--compat', { 'dest': 'compat', 'metavar': 'VERSION', + 'type': 'int', 'default': 2, + 'help': 'produce output with given compatibility VERSION' }), ('-H', '--hash', { 'dest': 'hash', 'metavar': 'HASH', ##'type': 'choice', 'choices': H.algorithms, 'help': 'use HASH as the hash function' })]: op.add_option(short, long, **props) -opts, args = op.parse_args(argv) - -if opts.udiff: - if opts.cache is None or opts.all or opts.files or len(args) > 2: +OPTS, args = op.parse_args(argv) +if not 1 <= OPTS.compat <= 2: + die("unknown compatibility version %d" % OPTS.compat) +if OPTS.udiff: + if OPTS.cache is None or OPTS.all or OPTS.files or len(args) > 2: die("incompatible options: `-u' requires `-c CACHE', forbids others") - db = HashCache(opts.cache, opts.hash) + db = HashCache(OPTS.cache, OPTS.hash) if len(args) == 2: OS.chdir(args[1]) good = True if not clear_cache(db): good = False if good: db.flush() else: exit(2) else: - if not opts.files and len(args) <= 1: + if not OPTS.files and len(args) <= 1: die("no filename sources: nothing to do") - db = HashCache(opts.cache, opts.hash) - if opts.all: + db = HashCache(OPTS.cache, OPTS.hash) + if OPTS.all: db.reset() + if OPTS.compat >= 2: + print "## fshash report format version %d" % OPTS.compat rep = Reporter(db) - if opts.files: - FMTMAP[opts.files](rep.file) + if OPTS.files: + FMTMAP[OPTS.files](rep.file) for dir in args[1:]: enum_walk(dir, rep.file) - if opts.all: + if OPTS.all: db.prune() db.flush()