Patchwork [11,of,15] speedy: make log -u and -d options query the history server

login
register
mail settings
Submitter Tomasz Kleczek
Date Dec. 11, 2012, 6:38 p.m.
Message ID <5527ac001fae8e214d1e.1355251106@dev408.prn1.facebook.com>
Download mbox | patch
Permalink /patch/58/
State Superseded
Headers show

Comments

Tomasz Kleczek - Dec. 11, 2012, 6:38 p.m.
# HG changeset patch
# User Tomasz Kleczek <tkleczek at fb.com>
# Date 1355182653 28800
# Branch stable
# Node ID 5527ac001fae8e214d1e78af0dfe34872fc27af0
# Parent  2fcc58f469d294c99f929b65d080637e6601242d
speedy: make log -u and -d options query the history server

Patch

diff --git a/hgext/speedy/client.py b/hgext/speedy/client.py
--- a/hgext/speedy/client.py
+++ b/hgext/speedy/client.py
@@ -8,6 +8,7 @@ 
 from mercurial import hg, discovery, util
 from mercurial import localrepo
 from mercurial.i18n import _
+from mercurial import cmdutil
 import server
 import protocol
 import tcptransport
@@ -93,6 +94,16 @@ 
         revs.update(revset.author(repo, lrevsall, ('symbol', pat)))
     return [r for r in subset if r in revs]
 
+def _patcheddate(metapeer, repo, subset, datestr):
+    """Return a list of revisions matching specified date.
+
+    metapeer: proxy object used to query the metadata server.
+    """
+    revs = set(metapeer.date(datestr))
+    lrevsall = metapeer.localrevs()
+    revs.update(revset.date(repo, lrevsall, ('symbol', datestr)))
+    return [ r for r in subset if r in revs ]
+
 def patchedauthor(metapeer, repo, subset, x):
     """Used to monkey patch revset.author function."""
     # We want to catch errors early and on client, if possible
@@ -100,18 +111,19 @@ 
     return _patchedauthor(metapeer, repo, subset, [pat])
 
 def patcheddate(metapeer, repo, subset, d):
-    """Return a list of revisions matching specified date.
-
-    metapeer: proxy object used to query the metadata server.
-
-    Used to monkey patch revset.date function.
-    """
+    """Used to monkey patch revset.date function."""
     # We want to catch errors early and on client, if possible
     ds = revset.getstring(d, _("date requires a string"))
-    revs = set(metapeer.date(ds))
-    lrevsall = metapeer.localrevs()
-    revs.update(revset.date(repo, lrevsall, ('symbol', ds)))
-    return [r for r in subset if r in revs]
+    return _patcheddate(metapeer, repo, subset, ds)
+
+def patchedfilterrevsopts(metapeer, repo, revs, opts):
+    users = opts.get('user')
+    date = opts.get('date')
+    if users:
+        revs = _patchedauthor(metapeer, repo, revs, users)
+    if date:
+        revs = _patcheddate(metapeer, repo, revs, date)
+    return revs
 
 def _speedysetup(ui, repo):
     """Initialize speedy client.
@@ -146,6 +158,7 @@ 
 
     revset.symbols['author'] = wrapwithpeer(patchedauthor, mpeer)
     revset.symbols['date'] = wrapwithpeer(patcheddate, mpeer)
+    cmdutil.walkchangerevshooks['filterrevsopts'] = wrapwithpeer(patchedfilterrevsopts, mpeer)
 
 def uisetup(ui):
     # Perform patching and most of the initialization inside log wrapper,
diff --git a/mercurial/cmdutil.py b/mercurial/cmdutil.py
--- a/mercurial/cmdutil.py
+++ b/mercurial/cmdutil.py
@@ -998,6 +998,13 @@ 
             if windowsize < sizelimit:
                 windowsize *= 2
 
+def filterrevsopts(repo, revs, opts):
+    return revs
+
+walkchangerevshooks = {
+    'filterrevsopts': filterrevsopts,
+}
+
 def walkchangerevs(repo, match, opts, prepare):
     '''Iterate over files and the revs in which they changed.
 
@@ -1024,6 +1031,8 @@ 
     else:
         revs = list(repo)
         revs.reverse()
+    revs = walkchangerevshooks['filterrevsopts'](repo, revs, opts)
+
     if not revs:
         return []
     wanted = set()
diff --git a/tests/test-speedy.t b/tests/test-speedy.t
--- a/tests/test-speedy.t
+++ b/tests/test-speedy.t
@@ -142,6 +142,19 @@ 
   $ hg log --rev "date(10/20/2012) & user(testuser2)"
   chg1
 
+  $ hg log -d "10/20/2012"
+  chg5
+  chg1
+
+  $ hg log -u "TESTUSER1"
+  chg8
+  chgl6
+  chg5
+  chg4
+  chg3
+  chg2
+  chg0
+
 Testing http server
 
 Writing server config file