Mercurial > hg > autobot
changeset 213:c35135b847fd
checkout the branch for hg; not sure if being on the wrong branch will fuxor things for the initial case
author | Jeff Hammel <jhammel@mozilla.com> |
---|---|
date | Wed, 09 Feb 2011 08:19:38 -0800 |
parents | 9f58383889c0 |
children | ee319fc010fa |
files | autobot/changes/poller.py |
diffstat | 1 files changed, 22 insertions(+), 18 deletions(-) [+] |
line wrap: on
line diff
--- 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)