hg log: add -k for keyword searching
authorMatt Mackall <mpm@selenic.com>
Mon, 03 Oct 2005 13:45:59 -0700
changeset 1373 965d1db5c95d
parent 1372 544633f0080d
child 1374 c3654cfaa77d
hg log: add -k for keyword searching
mercurial/commands.py
--- a/mercurial/commands.py	Mon Oct 03 12:52:45 2005 -0700
+++ b/mercurial/commands.py	Mon Oct 03 13:45:59 2005 -0700
@@ -1256,6 +1256,19 @@
             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 @@
          [('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]'),