# HG changeset patch # User Jeff Hammel # Date 1297268378 28800 # Node ID c35135b847fdf8a76890a009ba01f316cd43a21e # Parent 9f58383889c075aa57e6a416bebc9fb428526be8 checkout the branch for hg; not sure if being on the wrong branch will fuxor things for the initial case diff -r 9f58383889c0 -r c35135b847fd autobot/changes/poller.py --- a/autobot/changes/poller.py Fri Feb 04 17:45:34 2011 -0800 +++ b/autobot/changes/poller.py Wed Feb 09 08:19:38 2011 -0800 @@ -73,8 +73,8 @@ # # instead acquire self.initLock immediately when it is called. # if not self.isInitialized(): # log.msg('Initializing new repository') -# # d = self.initRepository() -# # d.addErrback(log.err, 'while initializing %s repository at %s' % (self.name, self.workdir)) +# d = self.initRepository() +# d.addErrback(log.err, 'while initializing %s repository at %s' % (self.name, self.workdir)) # else: # log.msg("%s repository already exists" % self.name) @@ -254,6 +254,8 @@ return f +### + class HgPoller(Poller): """poller for a mercurial source""" @@ -264,27 +266,34 @@ """is the repository initialized?""" return os.path.exists(os.path.join(self.workdir, '.hg')) + def checkoutBranch(self, _): + """checkout the branch""" + d = utils.getProcessOutput(self.binary, ['checkout', self.branch], + path=self.workdir, + env=dict(PATH=os.environ['PATH']), + errortoo=True) + return d + def initializationCommands(self): """commands to initialize a mercurial repository""" - commands = [ [ 'clone', self.repourl, self.workdir ] ] if self.branch != 'default': commands.append(['-r', self.workdir, 'checkout', self.branch]) return commands - def _fetch(self, _): - - # get a deferred object that performs the fetch + def update(self, _): args = ['pull', self.repourl] - # This command always produces data on stderr, but we actually do not care - # about the stderr or stdout from this command. We set errortoo=True to - # avoid an errback from the deferred. The callback which will be added to this - # deferred will not use the response. - d = utils.getProcessOutput(self.binary, args, path=self.workdir, env=dict(PATH=os.environ['PATH']), errortoo=True ) - + d = utils.getProcessOutput(self.binary, args, path=self.workdir, + env=dict(PATH=os.environ['PATH']), + errortoo=True ) return d + def _fetch(self, _): + d = self.checkoutBranch(None) + d.addCallback(self.update) + return d + def _hash(self, _): """commit hash""" d = utils.getProcessOutput(self.binary, ['tip', '--template', '{node}\\n'], @@ -417,7 +426,6 @@ def initializationCommands(self): """commands needed to initialize the repository""" - commands = [ [ 'clone', self.repourl, self.workdir ] ] if self.branch != 'master': git_dir = self.workdir.rstrip('/') + '/.git' @@ -431,7 +439,6 @@ errortoo=True) return d - def _fetch(self, _): d = self.checkoutBranch(None) d.addCallback(self.update) @@ -440,11 +447,8 @@ def _hash(self, _): """ get hash of where you are now: - git show-ref HEAD --hash - -or- git rev-parse HEAD - """ - + """ d = utils.getProcessOutput(self.binary, ['rev-parse', 'HEAD'], path=self.workdir, env=dict(PATH=os.environ['PATH']), errortoo=False)