# HG changeset patch # User mpm@selenic.com # Date 2005-08-24 03:21:52 # Node ID 836667830fee3fba9afb4efe315b531d9c773d86 # Parent 22571b8d35d3fce8c7d596579da586948ec928da Teach annotate about binary files diff --git a/doc/hg.1.txt b/doc/hg.1.txt --- a/doc/hg.1.txt +++ b/doc/hg.1.txt @@ -71,8 +71,13 @@ annotate [-r -u -n -c] [files ...] This command is useful to discover who did a change or when a change took place. + + Without the -a option, annotate will avoid processing files it + detects as binary. With -a, annotate will generate an annotation + anyway, probably with undesirable results. options: + -a, --text treat all files as text -I, --include include names matching the given patterns -X, --exclude exclude names matching the given patterns -r, --revision annotate the specified revision diff --git a/mercurial/commands.py b/mercurial/commands.py --- a/mercurial/commands.py +++ b/mercurial/commands.py @@ -433,12 +433,18 @@ def annotate(ui, repo, *pats, **opts): node = repo.dirstate.parents()[0] change = repo.changelog.read(node) mmap = repo.manifest.read(change[0]) + for src, abs, rel, exact in walk(repo, pats, opts): if abs not in mmap: ui.warn("warning: %s is not in the repository!\n" % rel) continue - lines = repo.file(abs).annotate(mmap[abs]) + f = repo.file(abs) + if not opts['text'] and util.binary(f.read(mmap[abs])): + ui.write("%s: binary file\n" % rel) + continue + + lines = f.annotate(mmap[abs]) pieces = [] for o, f in opmap: @@ -1285,6 +1291,7 @@ table = { "^annotate": (annotate, [('r', 'rev', '', 'revision'), + ('a', 'text', None, 'treat all files as text'), ('u', 'user', None, 'show user'), ('n', 'number', None, 'show revision number'), ('c', 'changeset', None, 'show changeset'),