Print this page
OS-1823 git-pbchk should not depend on mercurial

Split Close
Expand all
Collapse all
          --- old/usr/src/tools/scripts/git-pbchk.py
          +++ new/usr/src/tools/scripts/git-pbchk.py
↓ open down ↓ 9 lines elided ↑ open up ↑
  10   10  #  GNU General Public License for more details.
  11   11  #
  12   12  #  You should have received a copy of the GNU General Public License
  13   13  #  along with this program; if not, write to the Free Software
  14   14  #  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  15   15  #
  16   16  
  17   17  #
  18   18  # Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
  19   19  # Copyright 2008, 2012 Richard Lowe
       20 +# Copyright (c) 2013, Joyent Inc. All rights reserved.
  20   21  #
  21   22  
  22   23  import getopt
  23   24  import os
  24   25  import re
  25   26  import subprocess
  26   27  import sys
  27   28  import tempfile
  28   29  
  29   30  from cStringIO import StringIO
  30   31  
  31      -# This is necessary because, in a fit of pique, we used hg-format ignore lists
  32      -# for NOT files.
  33      -from mercurial import ignore
  34      -
  35   32  #
  36   33  # Adjust the load path based on our location and the version of python into
  37   34  # which it is being loaded.  This assumes the normal onbld directory
  38   35  # structure, where we are in bin/ and the modules are in
  39   36  # lib/python(version)?/onbld/Scm/.  If that changes so too must this.
  40   37  #
  41   38  sys.path.insert(1, os.path.join(os.path.dirname(__file__), "..", "lib",
  42   39                                  "python%d.%d" % sys.version_info[:2]))
  43   40  
  44   41  #
  45   42  # Add the relative path to usr/src/tools to the load path, such that when run
  46   43  # from the source tree we use the modules also within the source tree.
  47   44  #
  48   45  sys.path.insert(2, os.path.join(os.path.dirname(__file__), ".."))
  49   46  
       47 +from onbld.Scm import Ignore
  50   48  from onbld.Checks import Comments, Copyright, CStyle, HdrChk
  51   49  from onbld.Checks import JStyle, Keywords, Mapfile
  52   50  
  53   51  
  54   52  class GitError(Exception):
  55   53      pass
  56   54  
  57   55  def git(command):
  58   56      """Run a command and return a stream containing its stdout (and write its
  59   57      stderr to its stdout)"""
↓ open down ↓ 110 lines elided ↑ open up ↑
 170  168      return ret
 171  169  
 172  170  
 173  171  def not_check(root, cmd):
 174  172      """Return a function which returns True if a file given as an argument
 175  173      should be excluded from the check named by 'cmd'"""
 176  174  
 177  175      ignorefiles = filter(os.path.exists,
 178  176                           [os.path.join(root, ".git", "%s.NOT" % cmd),
 179  177                            os.path.join(root, "exception_lists", cmd)])
 180      -    if len(ignorefiles) > 0:
 181      -        return ignore.ignore(root, ignorefiles, sys.stderr.write)
 182      -    else:
 183      -        return lambda x: False
      178 +    return Ignore.ignore(root, ignorefiles)
 184  179  
 185  180  
 186  181  def gen_files(root, parent, paths, exclude):
 187  182      """Return a function producing file names, relative to the current
 188  183      directory, of any file changed on this branch (limited to 'paths' if
 189  184      requested), and excluding files for which exclude returns a true value """
 190  185  
 191  186      # Taken entirely from Python 2.6's os.path.relpath which we would use if we
 192  187      # could.
 193  188      def relpath(path, here):
↓ open down ↓ 179 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX