changeset 1373:965d1db5c95d

hg log: add -k for keyword searching
author Matt Mackall <mpm@selenic.com>
date Mon, 03 Oct 2005 13:45:59 -0700
parents 544633f0080d
children c3654cfaa77d
files mercurial/commands.py
diffstat 1 files changed, 14 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/commands.py
+++ b/mercurial/commands.py
@@ -1256,6 +1256,19 @@ def log(ui, repo, *pats, **opts):
             br = None
             if opts['branch']:
                 br = repo.branchlookup([repo.changelog.node(rev)])
+
+            if opts['keyword']:
+                changes = repo.changelog.read(repo.changelog.node(rev))
+                miss = 0
+                for k in opts['keyword']:
+                    if not (k in changes[1].lower() or
+                            k in changes[4].lower() or
+                            k in " ".join(changes[3][:20]).lower()):
+                        miss = 1
+                        break
+                if miss:
+                    continue
+
             show_changeset(du, repo, rev, brinfo=br)
             if opts['patch']:
                 changenode = repo.changelog.node(rev)
@@ -1868,6 +1881,7 @@ table = {
          [('I', 'include', [], 'include path in search'),
           ('X', 'exclude', [], 'exclude path from search'),
           ('b', 'branch', None, 'show branches'),
+          ('k', 'keyword', [], 'search for a keyword'),
           ('r', 'rev', [], 'revision'),
           ('p', 'patch', None, 'show patch')],
          'hg log [-I] [-X] [-r REV]... [-p] [FILE]'),