< prev index next >

./jcheck.py

Print this page
rev 127 : [mq]: pl

@@ -41,11 +41,11 @@
 # For more information: http://openjdk.java.net/projects/code-tools/jcheck/
 
 _version = "@VERSION@"
 _date = "@DATE@"
 
-import sys, os, re, urllib, urllib2, json, inspect
+import sys, os, re, urllib, urllib2, json, inspect, glob
 from mercurial.node import *
 from mercurial import cmdutil, context, error, patch, templater, util, utils
 try:
     # Mercurial 4.3 and higher
     from mercurial import registrar

@@ -531,10 +531,14 @@
         if self.conf.get("bugids") == "lax":
             self.bugids_lax = True
         self.bugids_ignore = False
         if self.conf.get("bugids") == "ignore":
             self.bugids_ignore = True
+        self.problem_list_patterns = []
+        if self.conf.get("problem_list_patterns"):
+            for pattern in self.conf.get("problem_list_patterns").split(":"):
+                self.problem_list_patterns.append(os.path.join(repo.root, *pattern.split("/")))
         if not self.bugids_ignore and not self.bugids_allow_dups:
             # only gather bug ids if we are going to use them
             self.repo_bugids = repo_bugids(ui, repo)
         self.blacklist = dict.fromkeys(changeset_blacklist)
         self.read_blacklist(blacklist_file)

@@ -676,10 +680,46 @@
     def c_03_hash(self, ctx):
         hash = hex(ctx.node())
         if hash in self.blacklist:
             self.error(ctx, "Blacklisted changeset: " + hash)
 
+    def c_04_problem_list(self, ctx):
+        if self.problem_list_patterns:
+
+            def get_bugs_from_problem_list(list):
+                result = set()
+                with open(list) as f:
+                    for line in f.readlines():
+                        line = line.strip()
+                        if not line.startswith('#'):
+                            a = line.split(None, 2)
+                            if len(a) > 1:
+                                bug = a[1]
+                                if bug.startswith('JDK-'):
+                                    bug = bug[4:]
+                                if bug.isdigit():
+                                    result.add(int(bug))
+                return result
+
+            problem_lists = [ ]
+            for pattern in self.problem_list_patterns:
+                problem_lists += glob.glob(pattern)
+
+            if self.ui.debugflag:
+                self.ui.debug("Problem list files: %s\n" % ", ".join(problem_lists))
+
+            problem_listed_bugs = set()
+            for problem_list in problem_lists:
+                problem_listed_bugs = problem_listed_bugs.union(get_bugs_from_problem_list(problem_list))
+
+            if self.ui.debugflag:
+                self.ui.debug("Currently problem listed bugs: %s\n" % ", ".join(str(b) for b in problem_listed_bugs))
+
+            for b in self.cs_bugids:
+                if b in problem_listed_bugs:
+                    self.error(ctx, "%d is still used in a problem list" % b)
+
     def check(self, rev, node):
         self.summarized = False
         self.cs_bugids = [ ]
         self.cs_author = None
         self.cs_reviewers = [ ]
< prev index next >