# HG changeset patch # User mpm@selenic.com # Date 1115335331 28800 # Node ID 642058291e74f1f44d901c7dabc19da2417f0aa0 # Parent 12f598340423c8d124e112e03a7c9c5d59bcc39c diffdir tidy in preparation for arg handling diff -r 12f598340423 -r 642058291e74 hg --- a/hg Thu May 05 15:20:56 2005 -0800 +++ b/hg Thu May 05 15:22:11 2005 -0800 @@ -38,6 +38,24 @@ diff [files...] diff working directory (or selected files) """ +def diffdir(node, files = None): + (c, a, d) = repo.diffdir(repo.root, node) + + if args: + nc = [ x for x in c if x in args ] + na = [ x for x in a if x in args ] + nd = [ x for x in d if x in args ] + for arg in args: + if not os.path.isdir(arg): continue + if arg[-1] != os.sep: arg += os.sep + nc += [ x for x in c if x.startswith(arg) ] + na += [ x for x in a if x.startswith(arg) ] + nd += [ x for x in d if x.startswith(arg) ] + (c, a, d) = (nc, na, nd) + + return (c, a, d) + + options = {} opts = [('v', 'verbose', None, 'verbose'), ('d', 'debug', None, 'debug')] @@ -88,9 +106,9 @@ elif cmd == "commit" or cmd == "checkin" or cmd == "ci": if 1: if len(args) > 0: - repo.commit(args) + repo.commit(repo.current, args) else: - repo.commit() + repo.commit(repo.current) elif cmd == "import" or cmd == "patch": ioptions = {} @@ -112,31 +130,19 @@ repo.commit(files) elif cmd == "status": - (c, a, d) = repo.diffdir(repo.root, repo.current) + (c, a, d) = diffdir(repo.current) for f in c: print "C", f for f in a: print "?", f for f in d: print "R", f elif cmd == "diff": + (c, a, d) = diffdir(repo.current, args) + mmap = {} if repo.current: change = repo.changelog.read(repo.current) mmap = repo.manifest.read(change[0]) - (c, a, d) = repo.diffdir(repo.root, repo.current) - - if args: - nc = [ x for x in c if x in args ] - na = [ x for x in a if x in args ] - nd = [ x for x in d if x in args ] - for arg in args: - if not os.path.isdir(arg): continue - if arg[-1] != os.sep: arg += os.sep - nc += [ x for x in c if x.startswith(arg) ] - na += [ x for x in a if x.startswith(arg) ] - nd += [ x for x in d if x.startswith(arg) ] - (c, a, d) = (nc, na, nd) - for f in c: to = repo.file(f).read(mmap[f]) tn = file(f).read()