From d73354aa1215fe36465d225aafb8fabdcd0ab2d3 Mon Sep 17 00:00:00 2001 From: Maria Marcano Date: Wed, 29 Jul 2015 10:46:36 +0200 Subject: [PATCH] Fix: Instead of pull everything should it be pull --rev (branch or rev-hash), hg pull (everything) will create a problem with any branch that has multiple heads (which is valid workflow in Mercurial). Depending on whether you pull a specific revision first, then pull everything, or pull everything first and then get a specific revision, the 'most recently changed head' can be different on the branch, and that can lead to inconsistent results between buildslaves. Command tested on a katana buildmaster. --- master/buildbot/steps/source/mercurial.py | 12 ++++++-- .../test/unit/test_steps_source_mercurial.py | 28 +++++++++---------- 2 files changed, 24 insertions(+), 16 deletions(-) diff --git a/master/buildbot/steps/source/mercurial.py b/master/buildbot/steps/source/mercurial.py index 1c6a2707620..0901482d599 100644 --- a/master/buildbot/steps/source/mercurial.py +++ b/master/buildbot/steps/source/mercurial.py @@ -148,7 +148,7 @@ def mode_incremental(self, _): @defer.inlineCallbacks def _cmd(updatable): if updatable: - yield self._dovccmd(['pull', self.repourl]) + yield self._dovccmd(self.getHgPullCommand()) return else: yield self._clone() @@ -221,8 +221,16 @@ def _checkBranchChange(self, _): log.msg(msg) yield self._removeAddedFilesAndUpdate(None) - def _pullUpdate(self, res): + def getHgPullCommand(self): command = ['pull', self.repourl] + if self.revision: + command.extend(['--rev', self.revision]) + elif self.branchType == 'inrepo': + command.extend(['--rev', self.update_branch]) + return command + + def _pullUpdate(self, res): + command = self.getHgPullCommand() d = self._dovccmd(command) d.addCallback(self._checkBranchChange) return d diff --git a/master/buildbot/test/unit/test_steps_source_mercurial.py b/master/buildbot/test/unit/test_steps_source_mercurial.py index caf8cabb5b1..a76e9e2aac8 100644 --- a/master/buildbot/test/unit/test_steps_source_mercurial.py +++ b/master/buildbot/test/unit/test_steps_source_mercurial.py @@ -78,7 +78,7 @@ def test_mode_full_clean(self): + 0, ExpectShell(workdir='wkdir', command=['hg', '--verbose', 'pull', - 'http://hg.mozilla.org']) + 'http://hg.mozilla.org', '--rev', 'default']) + 0, ExpectShell(workdir='wkdir', command=['hg', '--verbose', 'identify', '--branch']) @@ -124,7 +124,7 @@ def test_mode_full_clean_win32path(self): + 0, ExpectShell(workdir='wkdir', command=['hg', '--verbose', 'pull', - 'http://hg.mozilla.org']) + 'http://hg.mozilla.org', '--rev', 'default']) + 0, ExpectShell(workdir='wkdir', command=['hg', '--verbose', 'identify', '--branch']) @@ -173,7 +173,7 @@ def test_mode_full_clean_timeout(self): ExpectShell(workdir='wkdir', timeout=1, command=['hg', '--verbose', 'pull', - 'http://hg.mozilla.org']) + 'http://hg.mozilla.org', '--rev', 'default']) + 0, ExpectShell(workdir='wkdir', timeout=1, @@ -223,7 +223,7 @@ def test_mode_full_clean_patch(self): + 0, ExpectShell(workdir='wkdir', command=['hg', '--verbose', 'pull', - 'http://hg.mozilla.org']) + 'http://hg.mozilla.org', '--rev', 'default']) + 0, ExpectShell(workdir='wkdir', command=['hg', '--verbose', 'identify', '--branch']) @@ -286,7 +286,7 @@ def test_mode_full_clean_patch_fail(self): + 0, ExpectShell(workdir='wkdir', command=['hg', '--verbose', 'pull', - 'http://hg.mozilla.org']) + 'http://hg.mozilla.org', '--rev', 'default']) + 0, ExpectShell(workdir='wkdir', command=['hg', '--verbose', 'identify', '--branch']) @@ -404,7 +404,7 @@ def test_mode_full_fresh(self): + 0, ExpectShell(workdir='wkdir', command=['hg', '--verbose', 'pull', - 'http://hg.mozilla.org']) + 'http://hg.mozilla.org', '--rev', 'default']) + 0, ExpectShell(workdir='wkdir', command=['hg', '--verbose', 'identify', '--branch']) @@ -689,7 +689,7 @@ def test_mode_incremental_existing_repo(self): + 0, # directory exists ExpectShell(workdir='wkdir', command=['hg', '--verbose', 'pull', - 'http://hg.mozilla.org']) + 'http://hg.mozilla.org', '--rev', 'default']) + 0, ExpectShell(workdir='wkdir', command=['hg', '--verbose', 'identify', '--branch']) @@ -729,7 +729,7 @@ def test_mode_incremental_existing_repo_added_files(self): + 0, # directory exists ExpectShell(workdir='wkdir', command=['hg', '--verbose', 'pull', - 'http://hg.mozilla.org']) + 'http://hg.mozilla.org', '--rev', 'default']) + 0, ExpectShell(workdir='wkdir', command=['hg', '--verbose', 'identify', '--branch']) @@ -774,7 +774,7 @@ def test_mode_incremental_existing_repo_added_files_old_rmdir(self): + 0, # directory exists ExpectShell(workdir='wkdir', command=['hg', '--verbose', 'pull', - 'http://hg.mozilla.org']) + 'http://hg.mozilla.org', '--rev', 'default']) + 0, ExpectShell(workdir='wkdir', command=['hg', '--verbose', 'identify', '--branch']) @@ -824,7 +824,7 @@ def test_mode_incremental_given_revision(self): + 0, ExpectShell(workdir='wkdir', command=['hg', '--verbose', 'pull', - 'http://hg.mozilla.org']) + 'http://hg.mozilla.org', '--rev', 'abcdef01']) + 0, ExpectShell(workdir='wkdir', command=['hg', '--verbose', 'identify', '--branch']) @@ -866,7 +866,7 @@ def test_mode_incremental_branch_change(self): + 0, ExpectShell(workdir='wkdir', command=['hg', '--verbose', 'pull', - 'http://hg.mozilla.org']) + 'http://hg.mozilla.org', '--rev', 'stable']) + 0, ExpectShell(workdir='wkdir', command=['hg', '--verbose', 'identify', '--branch']) @@ -913,7 +913,7 @@ def test_mode_incremental_branch_change_no_clobberOnBranchChange(self): + 0, ExpectShell(workdir='wkdir', command=['hg', '--verbose', 'pull', - 'http://hg.mozilla.org']) + 'http://hg.mozilla.org', '--rev', 'stable']) + 0, ExpectShell(workdir='wkdir', command=['hg', '--verbose', 'identify', '--branch']) @@ -958,7 +958,7 @@ def test_mode_full_clean_env(self): + 0, ExpectShell(workdir='wkdir', command=['hg', '--verbose', 'pull', - 'http://hg.mozilla.org'], env={'abc': '123'}) + 'http://hg.mozilla.org', '--rev', 'default'], env={'abc': '123'}) + 0, ExpectShell(workdir='wkdir', command=['hg', '--verbose', 'identify', '--branch'], @@ -1009,7 +1009,7 @@ def test_mode_full_clean_logEnviron(self): + 0, ExpectShell(workdir='wkdir', command=['hg', '--verbose', 'pull', - 'http://hg.mozilla.org'], + 'http://hg.mozilla.org', '--rev', 'default'], logEnviron=False) + 0, ExpectShell(workdir='wkdir',