< prev index next >

./jcheck.py

Print this page
rev 113 : Allow start=YYYY-MM-DD in .jcheck/conf; older changesets are not checked

@@ -42,10 +42,11 @@
 
 _version = "@VERSION@"
 _date = "@DATE@"
 
 import sys, os, re, urllib, urllib2
+from datetime import date
 from mercurial.node import *
 from mercurial import cmdutil, patch, util, context, templater
 
 Pass = False
 Fail = True

@@ -57,10 +58,15 @@
 def oneline(ctx):
     return ("%5d:%s  %-12s  %s  %s\n"
             % (ctx.rev(), short(ctx.node()), ctx.user(), datestr(ctx),
                ctx.description().splitlines()[0]))
 
+# Take a date string of the form YYYY-MM-DD and return a date
+def todate(dstr):
+    darr = dstr.split('-')
+    return date(int(darr[0]), int(darr[1]), int(darr[2]))
+
 def is_merge(repo, rev):
     return not (-1 in repo.changelog.parentrevs(rev))
 
 _matchall = getattr(cmdutil, 'matchall', None)
 if not _matchall:

@@ -490,10 +496,17 @@
         if self.conf.get("bugids") == "ignore":
             self.bugids_ignore = True
         if not self.bugids_ignore:
             # only identify bug ids if we are going to use them
             self.repo_bugids = repo_bugids(ui, repo)
+        self.use_start = False
+        self.startdate = None
+        startstr = self.conf.get("start")
+        if startstr != None:
+            self.use_start = True
+            self.startdate = todate(startstr)
+        ui.debug("self.use_start = %s, self.startdate = %s\n" % (self.use_start, self.startdate))
         self.blacklist = dict.fromkeys(changeset_blacklist)
         self.read_blacklist(blacklist_file)
         # hg < 1.0 does not have localrepo.tagtype()
         self.tagtype = getattr(self.repo, 'tagtype', lambda k: 'global')
 

@@ -633,10 +646,18 @@
     def c_03_hash(self, ctx):
         hash = hex(ctx.node())
         if hash in self.blacklist:
             self.error(ctx, "Blacklisted changeset: " + hash)
 
+    def before_start(self, ctx):
+        if not self.use_start:
+            return False
+        csdatestr = datestr(ctx).split()[0]
+        csdate = todate(csdatestr)
+        self.ui.debug("startdate = %s, cs date = %s\n" % (self.startdate, csdate))
+        return csdate < self.startdate
+
     def check(self, node):
         self.summarized = False
         self.cs_bugids = [ ]
         self.cs_author = None
         self.cs_reviewers = [ ]

@@ -644,10 +665,14 @@
         ctx = context.changectx(self.repo, node)
         self.ui.note(oneline(ctx))
         if not self.strict and hex(node) in changeset_whitelist:
             self.ui.note("%s in whitelist; skipping\n" % hex(node))
             return Pass
+        if self.before_start(ctx):
+            # Before start date; only do blacklist check
+            self.c_03_hash(ctx);
+            return self.rv
         for c in self.checks:
             cf = checker.__dict__[c]
             cf(self, ctx)
         return self.rv
 
< prev index next >