firstpushdate() revspec
authorGregory Szorc <gps@mozilla.com>
Fri, 08 Nov 2013 09:23:09 -0800
changeset 72 35bb3c96d786f842f2776c17a37b4aacbc4c481a
parent 71 fb1e21435cdffb77c492547c82d22521363546a8
child 73 e055c35a87ee7d03bd9236933f10e18b74cfb614
push id52
push usergszorc@mozilla.com
push dateFri, 08 Nov 2013 17:23:13 +0000
firstpushdate() revspec
__init__.py
--- a/__init__.py
+++ b/__init__.py
@@ -128,16 +128,19 @@ me()
    changesets you reviewed (via mozext.ircnick).
 
 nobug()
    Retrieve changesets that don't reference a bug in the commit message.
 
 pushhead([TREE])
    Retrieve changesets that are push heads.
 
+firstpushdate(DATE)
+   Retrieve changesets that were first pushed according to the date spec.
+
 firstpushtree(TREE)
    Retrieve changesets that initially landed on the specified tree.
 
 reviewer(REVIEWER)
    Retrieve changesets there were reviewed by the specified person.
 
    The reviewer string matches the *r=* string specified in the commit. In
    the future, we may consult a database of known aliases, etc.
@@ -775,16 +778,35 @@ def revset_tree(repo, subset, x):
     ref = '%s/default' % tree
 
     head = repo[ref].rev()
     ancestors = set(repo.changelog.ancestors([head], inclusive=True))
 
     return [r for r in subset if r in ancestors]
 
 
+def revset_firstpushdate(repo, subset, x):
+    """``firstpushdate(DATE)``
+    Changesets that were initially pushed according to the date spec provided.
+    """
+    ds = revset.getstring(x, _('firstpushdate() requires a string'))
+    dm = util.matchdate(ds)
+
+    for rev in subset:
+        pushes = list(repo.changetracker.pushes_for_changeset(repo[rev].node()))
+
+        if not pushes:
+            continue
+
+        when = pushes[0][2]
+
+        if dm(when):
+            yield rev
+
+
 def revset_firstpushtree(repo, subset, x):
     """``firstpushtree(X)``
     Changesets that were initially pushed to tree X.
     """
     tree = revset.getstring(x, _('firstpushtree() requires a string argument.'))
 
     tree, uri = resolve_trees_to_uris([tree])[0]
     if not uri:
@@ -1057,16 +1079,17 @@ def extsetup(ui):
     revset.symbols['bug'] = revset_bug
     revset.symbols['dontbuild'] = revset_dontbuild
     revset.symbols['me'] = revset_me
     revset.symbols['nobug'] = revset_nobug
     revset.symbols['pushhead'] = revset_pushhead
     revset.symbols['reviewer'] = revset_reviewer
     revset.symbols['reviewed'] = revset_reviewed
     revset.symbols['tree'] = revset_tree
+    revset.symbols['firstpushdate'] = revset_firstpushdate
     revset.symbols['firstpushtree'] = revset_firstpushtree
 
     templatekw.keywords['bug'] = template_bug
     templatekw.keywords['bugs'] = template_bugs
     templatekw.keywords['reviewer'] = template_reviewer
     templatekw.keywords['reviewers'] = template_reviewers
     templatekw.keywords['firstrelease'] = template_firstrelease
     templatekw.keywords['firstbeta'] = template_firstbeta