Ticket #277: buildbot-hg-pull-command.patch

File buildbot-hg-pull-command.patch, 2.6 kB (added by bsmedberg, 4 months ago)

patch for commands.py

  • buildbot/slave/commands.py

    old new  
    20922092    def sourcedirIsUpdateable(self): 
    20932093        if os.path.exists(os.path.join(self.builder.basedir, 
    20942094                                       self.srcdir, ".buildbot-patched")): 
    20952095            return False 
    2096         # like Darcs, to check out a specific (old) revision, we have to do a 
    2097         # full checkout. TODO: I think 'hg pull' plus 'hg update' might work 
    2098         if self.revision: 
    2099             return False 
    21002096        return os.path.isdir(os.path.join(self.builder.basedir, 
    21012097                                          self.srcdir, ".hg")) 
    21022098 
    21032099    def doVCUpdate(self): 
    21042100        d = os.path.join(self.builder.basedir, self.srcdir) 
    2105         command = [self.vcexe, 'pull', '--update', '--verbose'] 
    2106         if self.args['revision']: 
    2107             command.extend(['--rev', self.args['revision']]) 
     2101        command = [self.vcexe, 'pull', '--verbose'] 
    21082102        c = ShellCommand(self.builder, command, d, 
    21092103                         sendRC=False, timeout=self.timeout, 
    21102104                         keepStdout=True) 
    21112105        self.command = c 
     
    21132107        d.addCallback(self._handleEmptyUpdate) 
    21142108        return d 
    21152109 
    21162110    def _handleEmptyUpdate(self, res): 
     2111        if res == 0: 
     2112            return self._doUpdate() 
     2113 
    21172114        if type(res) is int and res == 1: 
    21182115            if self.command.stdout.find("no changes found") != -1: 
    21192116                # 'hg pull', when it doesn't have anything to do, exits with 
    21202117                # rc=1, and there appears to be no way to shut this off. It 
    21212118                # emits a distinctive message to stdout, though. So catch 
    21222119                # this and pretend that it completed successfully. 
    2123                 return 0 
     2120                return self._doUpdate() 
    21242121        return res 
    21252122 
     2123    def _doUpdate(self): 
     2124        dir = os.path.join(self.builder.basedir, self.srcdir) 
     2125        # When cloning a tree without a specified revision, you get the tip of the default 
     2126        # branch. Do the same thing when updating a tree without a specified revision. 
     2127        if self.args['revision']: 
     2128            rev = self.args['revision'] 
     2129        else: 
     2130            rev = 'default' 
     2131        command = [self.vcexe, 'update', '-C', '--rev', rev] 
     2132        c = ShellCommand(self.builder, command, dir, 
     2133                         sendRC=False, timeout=self.timeout, 
     2134                         keepStdout=True) 
     2135        return c.start() 
     2136 
    21262137    def doVCFull(self): 
    21272138        d = os.path.join(self.builder.basedir, self.srcdir) 
    21282139        command = [self.vcexe, 'clone'] 
    21292140        if self.args['revision']: