Commits

Patrick Mézard committed ccfcb53

Add --date option to filter patches by date

Comments (0)

Files changed (5)

                 continue
             yield msg
 
-def listgroups(paths):
+def listgroups(paths, datefn):
     pendings = {}
     for m in listmessages(paths):
+        if not datefn(m.date()):
+            continue
         if m.count == 1:
             yield None, [m]
             continue
     selecteds = []
     stop = False
 
-    groups = filter(matcher, listgroups(paths))
+    datefn = util.always
+    if opts.get('date'):
+        datefn = util.matchdate(opts.get('date'))
+    groups = filter(matcher, listgroups(paths, datefn))
     def cmpgroup(a, b):
         return -cmp(a[1][0].date(), b[1][0].date())
     groups.sort(cmpgroup)
     except KeyError:
         return
 
-    cmdtable['mimport'] = (mimport, [], _('hg mimport PATTERN...'))
+    cmdtable['mimport'] = (
+        mimport, 
+        [('d', 'date', '', _('show patches matching date spec')),
+         ], 
+        _('hg mimport PATTERN...'))
 y
 EOF
 hg qseries
+
+echo % test filtering by date
+hg mimport -d '<2008-12-16' <<EOF
+y
+EOF
+
+
 patch2__1
 patch1
 patch2
+% test filtering by date
+[PATCH] patch1
+import this group? [Nydq?]  
+adding patch1__1 to series file
+1 patches imported
 MIME-Version: 1.0
 Subject: [PATCH] patch1
 Message-Id: <5ab3c4562bd574dbd782.1230599538@localhost>
-Date: Tue, 30 Dec 2008 02:12:18 +0100
+Date: Tue, 16 Dec 2008 02:12:18 +0100
 From: Bar Baz <barbaz@gmail.com>
 To: mercurial-devel@selenic.com
 Content-Type: text/plain; charset="us-ascii"
-From MAILER-DAEMON Sat Jan  3 10:11:04 2009
+From MAILER-DAEMON Sat Jan  3 10:45:19 2009
 Delivered-To: foobar@gmail.com
 Received: by 10.114.108.3 with SMTP id g3cs509927wac;
         Mon, 29 Dec 2008 17:13:30 -0800 (PST)
 MIME-Version: 1.0
 Subject: [PATCH] patch1
 Message-Id: <5ab3c4562bd574dbd782.1230599538@localhost>
-Date: Tue, 30 Dec 2008 02:12:18 +0100
+Date: Tue, 16 Dec 2008 02:12:18 +0100
 From: Bar Baz <barbaz@gmail.com>
 To: mercurial-devel@selenic.com
 Content-Type: text/plain; charset="us-ascii"
 Mercurial-devel mailing list
 Mercurial-devel@selenic.com
 http://selenic.com/mailman/listinfo/mercurial-devel
-From MAILER-DAEMON Sat Jan  3 10:11:04 2009
+From MAILER-DAEMON Sat Jan  3 10:45:19 2009
 Delivered-To: foobar@gmail.com
 Received: by 10.114.108.3 with SMTP id g3cs509927wac;
         Mon, 29 Dec 2008 17:13:30 -0800 (PST)
 Mercurial-devel mailing list
 Mercurial-devel@selenic.com
 http://selenic.com/mailman/listinfo/mercurial-devel
-From MAILER-DAEMON Sat Jan  3 10:11:04 2009
+From MAILER-DAEMON Sat Jan  3 10:45:19 2009
 Delivered-To: foobar@gmail.com
 Received: by 10.114.108.3 with SMTP id g3cs509927wac;
         Mon, 29 Dec 2008 17:13:30 -0800 (PST)