Ticket #140: commands.py_2.patch

File commands.py_2.patch, 2.1 KB (added by amax_snaplogic, 2 years ago)

Patch adding buildbot.slave.commands.SVN.getSvnVersionCommand()

  • buildbot/slave/commands.py

    old new  
    14941494        self.command = c 
    14951495        return c.start() 
    14961496 
    1497     def parseGotRevision(self): 
     1497    def getSvnVersionCommand(self): 
     1498        """ 
     1499        Get the (shell) command used to determine SVN revision number 
     1500        of checked-out code 
     1501 
     1502        return: list of strings, passable as the command argument to ShellCommand 
     1503        """ 
    14981504        # svn checkout operations finish with 'Checked out revision 16657.' 
    14991505        # svn update operations finish the line 'At revision 16654.' 
    15001506        # But we don't use those. Instead, run 'svnversion'. 
    15011507        svnversion_command = getCommand("svnversion") 
    15021508        # older versions of 'svnversion' (1.1.4) require the WC_PATH 
    15031509        # argument, newer ones (1.3.1) do not. 
    1504         command = [svnversion_command, "."] 
    1505         c = ShellCommand(self.builder, command, 
     1510        return [svnversion_command, "."] 
     1511 
     1512    def parseGotRevision(self): 
     1513        c = ShellCommand(self.builder, 
     1514                         self.getSvnVersionCommand(), 
    15061515                         os.path.join(self.builder.basedir, self.srcdir), 
    15071516                         environ=self.env, 
    15081517                         sendStdout=False, sendStderr=False, sendRC=False, 
     
    15101519        c.usePTY = False 
    15111520        d = c.start() 
    15121521        def _parse(res): 
    1513             r = c.stdout.strip() 
    1514             # Support for removing svnversion indicator for 'modified' 
    1515             if r[-1] == 'M': 
    1516                 r = r[:-1] 
     1522            r_raw = c.stdout.strip() 
     1523            # Extract revision from the version "number" string 
     1524            r = r_raw.rstrip('MS') 
     1525            r = r.split(':')[-1] 
    15171526            got_version = None 
    15181527            try: 
    15191528                got_version = int(r) 
    15201529            except ValueError: 
    15211530                msg =("SVN.parseGotRevision unable to parse output " 
    1522                       "of svnversion: '%s'" % r) 
     1531                      "of svnversion: '%s'" % r_raw) 
    15231532                log.msg(msg) 
    15241533                self.sendStatus({'header': msg + "\n"}) 
    15251534            return got_version