launchpad-reviewers team mailing list archive
-
launchpad-reviewers team
-
Mailing list archive
-
Message #00626
[Merge] lp:~thumper/launchpad/new-bzr into lp:launchpad/devel
Tim Penhey has proposed merging lp:~thumper/launchpad/new-bzr into lp:launchpad/devel.
Requested reviews:
Launchpad code reviewers (launchpad-reviewers)
Upgrade bzr to 2.2.
Due to changes in bzrlib, specific user logins are needed, but there is a bug (which has been fixed on trunk) where the committer passed in as an argument was ignored.
--
https://code.launchpad.net/~thumper/launchpad/new-bzr/+merge/32845
Your team Launchpad code reviewers is requested to review the proposed merge of lp:~thumper/launchpad/new-bzr into lp:launchpad/devel.
=== modified file 'configs/development/apidoc-configure-normal.zcml'
--- configs/development/apidoc-configure-normal.zcml 2010-07-24 02:27:19 +0000
+++ configs/development/apidoc-configure-normal.zcml 2010-08-17 04:46:45 +0000
@@ -90,7 +90,6 @@
<apidoc:rootModule module="martian" />
<apidoc:rootModule module="manuel" />
<apidoc:rootModule module="chameleon" />
- <apidoc:rootModule module="bzrlib" />
<apidoc:rootModule module="storm" />
<apidoc:bookchapter
=== modified file 'lib/lp/code/mail/codehandler.py'
--- lib/lp/code/mail/codehandler.py 2010-08-02 02:51:42 +0000
+++ lib/lp/code/mail/codehandler.py 2010-08-17 04:46:45 +0000
@@ -545,8 +545,12 @@
# access to any needed but not supplied revisions.
md.target_branch = target_url
md.install_revisions(bzr_branch.repository)
- bzr_branch.pull(bzr_branch, stop_revision=md.revision_id,
- overwrite=True)
+ bzr_branch.lock_write()
+ try:
+ bzr_branch.pull(bzr_branch, stop_revision=md.revision_id,
+ overwrite=True)
+ finally:
+ bzr_branch.unlock()
def findMergeDirectiveAndComment(self, message):
"""Extract the comment and Merge Directive from a SignedMessage."""
=== modified file 'lib/lp/code/mail/tests/test_codehandler.py'
--- lib/lp/code/mail/tests/test_codehandler.py 2010-07-27 05:30:04 +0000
+++ lib/lp/code/mail/tests/test_codehandler.py 2010-08-17 04:46:45 +0000
@@ -3,6 +3,8 @@
"""Testing the CodeHandler."""
+from __future__ import with_statement
+
__metaclass__ = type
from difflib import unified_diff
@@ -48,6 +50,7 @@
from lp.codehosting.vfs import get_lp_server
from lp.registry.interfaces.person import IPersonSet
from lp.services.job.runner import JobRunner
+from lp.services.osutils import override_environ
from lp.testing import login, login_person, TestCase, TestCaseWithFactory
from lp.testing.mail_helpers import pop_notifications
@@ -888,12 +891,16 @@
db_target_branch, target_tree = self.create_branch_and_tree(
tree_location='.', format=format)
target_tree.branch.set_public_branch(db_target_branch.bzr_identity)
- target_tree.commit('rev1')
- # Make sure that the created branch has been mirrored.
- removeSecurityProxy(db_target_branch).branchChanged(
- '', 'rev1', None, None, None)
- source_tree = target_tree.bzrdir.sprout('source').open_workingtree()
- source_tree.commit('rev2')
+ # XXX: AaronBentley 2010-08-06 bug=614404: a bzr username is
+ # required to generate the revision-id.
+ with override_environ(BZR_EMAIL='me@xxxxxxxxxxx'):
+ target_tree.commit('rev1')
+ # Make sure that the created branch has been mirrored.
+ removeSecurityProxy(db_target_branch).branchChanged(
+ '', 'rev1', None, None, None)
+ sprout_bzrdir = target_tree.bzrdir.sprout('source')
+ source_tree = sprout_bzrdir.open_workingtree()
+ source_tree.commit('rev2')
message = self.factory.makeBundleMergeDirectiveEmail(
source_tree.branch, db_target_branch)
return db_target_branch, source_tree.branch, message
@@ -994,7 +1001,10 @@
branch, source, message = self._createTargetSourceAndBundle(
format="1.9")
target_tree = WorkingTree.open('.')
- target_tree.commit('rev2b')
+ # XXX: AaronBentley 2010-08-06 bug=614404: a bzr username is
+ # required to generate the revision-id.
+ with override_environ(BZR_EMAIL='me@xxxxxxxxxxx'):
+ target_tree.commit('rev2b')
bmp = self._processMergeDirective(message)
lp_branch = self._openBazaarBranchAsClient(bmp.source_branch)
self.assertEqual(source.last_revision(), lp_branch.last_revision())
@@ -1005,20 +1015,24 @@
db_target_branch, target_tree = self.create_branch_and_tree(
'target', format=target_format)
target_tree.branch.set_public_branch(db_target_branch.bzr_identity)
- revid = target_tree.commit('rev1')
- removeSecurityProxy(db_target_branch).branchChanged(
- '', revid, None, None, None)
+ # XXX: AaronBentley 2010-08-06 bug=614404: a bzr username is
+ # required to generate the revision-id.
+ with override_environ(BZR_EMAIL='me@xxxxxxxxxxx'):
+ revid = target_tree.commit('rev1')
+ removeSecurityProxy(db_target_branch).branchChanged(
+ '', revid, None, None, None)
- db_source_branch, source_tree = self.create_branch_and_tree(
- 'lpsource', db_target_branch.product, format=source_format)
- # The branch is not scheduled to be mirrorred.
- self.assertIs(db_source_branch.next_mirror_time, None)
- source_tree.pull(target_tree.branch)
- source_tree.commit('rev2', rev_id='rev2')
- # bundle_tree is effectively behaving like a local copy of
- # db_source_branch, and is used to create the merge directive.
- bundle_tree = source_tree.bzrdir.sprout('source').open_workingtree()
- bundle_tree.commit('rev3', rev_id='rev3')
+ db_source_branch, source_tree = self.create_branch_and_tree(
+ 'lpsource', db_target_branch.product, format=source_format)
+ # The branch is not scheduled to be mirrorred.
+ self.assertIs(db_source_branch.next_mirror_time, None)
+ source_tree.pull(target_tree.branch)
+ source_tree.commit('rev2', rev_id='rev2')
+ # bundle_tree is effectively behaving like a local copy of
+ # db_source_branch, and is used to create the merge directive.
+ sprout_bzrdir = source_tree.bzrdir.sprout('source')
+ bundle_tree = sprout_bzrdir.open_workingtree()
+ bundle_tree.commit('rev3', rev_id='rev3')
bundle_tree.branch.set_public_branch(db_source_branch.bzr_identity)
message = self.factory.makeBundleMergeDirectiveEmail(
bundle_tree.branch, db_target_branch,
=== modified file 'lib/lp/code/model/diff.py'
--- lib/lp/code/model/diff.py 2010-08-02 02:13:52 +0000
+++ lib/lp/code/model/diff.py 2010-08-17 04:46:45 +0000
@@ -140,7 +140,7 @@
source_revision)
merger = Merge3Merger(
merge_target, merge_target, merge_base, merge_source,
- do_merge=False)
+ this_branch=target_branch, do_merge=False)
def dummy_warning(self, *args, **kwargs):
pass
real_warning = trace.warning
=== modified file 'lib/lp/code/model/directbranchcommit.py'
--- lib/lp/code/model/directbranchcommit.py 2010-05-15 17:43:59 +0000
+++ lib/lp/code/model/directbranchcommit.py 2010-08-17 04:46:45 +0000
@@ -3,6 +3,8 @@
"""Commit files straight to bzr branch."""
+from __future__ import with_statement
+
__metaclass__ = type
__all__ = [
'ConcurrentUpdateError',
@@ -19,6 +21,8 @@
from canonical.launchpad.interfaces import IMasterObject
from lp.codehosting.bzrutils import get_stacked_on_url
+from lp.services.osutils import override_environ
+from lp.services.mail.sendmail import format_address_for_person
class ConcurrentUpdateError(Exception):
"""Bailout exception for concurrent updates.
@@ -188,8 +192,12 @@
if rev_id == NULL_REVISION:
if list(self.transform_preview.iter_changes()) == []:
return
- new_rev_id = self.transform_preview.commit(
- self.bzrbranch, commit_message)
+ committer_id = format_address_for_person(self.committer)
+ # XXX: AaronBentley 2010-08-06 bug=614404: a bzr username is
+ # required to generate the revision-id.
+ with override_environ(BZR_EMAIL=committer_id):
+ new_rev_id = self.transform_preview.commit(
+ self.bzrbranch, commit_message, committer=committer_id)
IMasterObject(self.db_branch).branchChanged(
get_stacked_on_url(self.bzrbranch), new_rev_id,
self.db_branch.control_format, self.db_branch.branch_format,
=== modified file 'lib/lp/code/model/tests/test_branch.py'
--- lib/lp/code/model/tests/test_branch.py 2010-08-12 01:53:07 +0000
+++ lib/lp/code/model/tests/test_branch.py 2010-08-17 04:46:45 +0000
@@ -84,6 +84,7 @@
from lp.testing.factory import LaunchpadObjectFactory
from lp.translations.model.translationtemplatesbuildjob import (
ITranslationTemplatesBuildJobSource)
+from lp.services.osutils import override_environ
class TestCodeImport(TestCase):
@@ -2573,7 +2574,10 @@
# safe_open returns the underlying bzr branch of a database branch in
# the simple, unstacked, case.
db_branch, tree = self.create_branch_and_tree()
- revid = tree.commit('')
+ # XXX: AaronBentley 2010-08-06 bug=614404: a bzr username is
+ # required to generate the revision-id.
+ with override_environ(BZR_EMAIL='me@xxxxxxxxxxx'):
+ revid = tree.commit('')
bzr_branch = db_branch.getBzrBranch()
self.assertEqual(revid, bzr_branch.last_revision())
=== modified file 'lib/lp/code/model/tests/test_branchjob.py'
--- lib/lp/code/model/tests/test_branchjob.py 2010-07-29 08:06:07 +0000
+++ lib/lp/code/model/tests/test_branchjob.py 2010-08-17 04:46:45 +0000
@@ -3,6 +3,8 @@
"""Tests for BranchJobs."""
+from __future__ import with_statement
+
__metaclass__ = type
import datetime
@@ -41,6 +43,7 @@
from lp.testing.mail_helpers import pop_notifications
from lp.services.job.interfaces.job import JobStatus
from lp.services.job.model.job import Job
+from lp.services.osutils import override_environ
from lp.code.bzr import BranchFormat, RepositoryFormat
from lp.code.enums import (
BranchMergeProposalStatus, BranchSubscriptionDiffSize,
@@ -104,7 +107,10 @@
"""Ensure that run calculates revision ids."""
self.useBzrBranches(direct_database=True)
branch, tree = self.create_branch_and_tree()
- tree.commit('First commit', rev_id='rev1')
+ # XXX: AaronBentley 2010-08-06 bug=614404: a bzr username is
+ # required to generate the revision-id.
+ with override_environ(BZR_EMAIL='me@xxxxxxxxxxx'):
+ tree.commit('First commit', rev_id='rev1')
job = BranchDiffJob.create(branch, '0', '1')
static_diff = job.run()
self.assertEqual('null:', static_diff.from_revision_id)
@@ -122,9 +128,12 @@
tree_file = os.path.join(tree_location, 'file')
open(tree_file, 'wb').write('foo\n')
tree.add('file')
- tree.commit('First commit')
- open(tree_file, 'wb').write('bar\n')
- tree.commit('Next commit')
+ # XXX: AaronBentley 2010-08-06 bug=614404: a bzr username is
+ # required to generate the revision-id.
+ with override_environ(BZR_EMAIL='me@xxxxxxxxxxx'):
+ tree.commit('First commit')
+ open(tree_file, 'wb').write('bar\n')
+ tree.commit('Next commit')
job = BranchDiffJob.create(branch, '1', '2')
static_diff = job.run()
transaction.commit()
@@ -138,7 +147,10 @@
"""Ensure running an equivalent job emits the same diff."""
self.useBzrBranches(direct_database=True)
branch, tree = self.create_branch_and_tree()
- tree.commit('First commit')
+ # XXX: AaronBentley 2010-08-06 bug=614404: a bzr username is
+ # required to generate the revision-id.
+ with override_environ(BZR_EMAIL='me@xxxxxxxxxxx'):
+ tree.commit('First commit')
job1 = BranchDiffJob.create(branch, '0', '1')
static_diff1 = job1.run()
job2 = BranchDiffJob.create(branch, '0', '1')
@@ -157,7 +169,10 @@
tree_transport = tree.bzrdir.root_transport
tree_transport.put_bytes("hello.txt", "Hello World\n")
tree.add('hello.txt')
- tree.commit('rev1', timestamp=1e9, timezone=0)
+ # XXX: AaronBentley 2010-08-06 bug=614404: a bzr username is
+ # required to generate the revision-id.
+ with override_environ(BZR_EMAIL='me@xxxxxxxxxxx'):
+ tree.commit('rev1', timestamp=1e9, timezone=0)
job = BranchDiffJob.create(branch, '0', '1')
diff = job.run()
transaction.commit()
@@ -202,20 +217,23 @@
self.useBzrBranches(direct_database=True)
db_branch, bzr_tree = self.create_branch_and_tree()
- bzr_tree.commit('First commit', rev_id='rev1')
- bzr_tree.commit('Second commit', rev_id='rev2')
- bzr_tree.commit('Third commit', rev_id='rev3')
- LaunchpadZopelessLayer.commit()
-
- job = BranchScanJob.create(db_branch)
- LaunchpadZopelessLayer.switchDbUser(config.branchscanner.dbuser)
- job.run()
- LaunchpadZopelessLayer.switchDbUser(config.launchpad.dbuser)
-
- self.assertEqual(db_branch.revision_count, 3)
-
- bzr_tree.commit('Fourth commit', rev_id='rev4')
- bzr_tree.commit('Fifth commit', rev_id='rev5')
+ # XXX: AaronBentley 2010-08-06 bug=614404: a bzr username is
+ # required to generate the revision-id.
+ with override_environ(BZR_EMAIL='me@xxxxxxxxxxx'):
+ bzr_tree.commit('First commit', rev_id='rev1')
+ bzr_tree.commit('Second commit', rev_id='rev2')
+ bzr_tree.commit('Third commit', rev_id='rev3')
+ LaunchpadZopelessLayer.commit()
+
+ job = BranchScanJob.create(db_branch)
+ LaunchpadZopelessLayer.switchDbUser(config.branchscanner.dbuser)
+ job.run()
+ LaunchpadZopelessLayer.switchDbUser(config.launchpad.dbuser)
+
+ self.assertEqual(db_branch.revision_count, 3)
+
+ bzr_tree.commit('Fourth commit', rev_id='rev4')
+ bzr_tree.commit('Fifth commit', rev_id='rev5')
job = BranchScanJob.create(db_branch)
LaunchpadZopelessLayer.switchDbUser(config.branchscanner.dbuser)
@@ -381,7 +399,10 @@
branch, tree = self.create_branch_and_tree()
tree.bzrdir.root_transport.put_bytes('foo', 'bar\n')
tree.add('foo')
- tree.commit('First commit')
+ # XXX: AaronBentley 2010-08-06 bug=614404: a bzr username is
+ # required to generate the revision-id.
+ with override_environ(BZR_EMAIL='me@xxxxxxxxxxx'):
+ tree.commit('First commit')
job = RevisionMailJob.create(
branch, 1, 'from@xxxxxxxxxxx', 'hello', True, 'subject')
mailer = job.getMailer()
@@ -477,9 +498,12 @@
branch, tree = self.create_branch_and_tree()
tree.lock_write()
try:
- tree.commit('rev1', rev_id='rev1')
- tree.commit('rev2', rev_id='rev2')
- tree.commit('rev3', rev_id='rev3')
+ # XXX: AaronBentley 2010-08-06 bug=614404: a bzr username is
+ # required to generate the revision-id.
+ with override_environ(BZR_EMAIL='me@xxxxxxxxxxx'):
+ tree.commit('rev1', rev_id='rev1')
+ tree.commit('rev2', rev_id='rev2')
+ tree.commit('rev3', rev_id='rev3')
transaction.commit()
self.layer.switchDbUser('branchscanner')
self.updateDBRevisions(
@@ -504,7 +528,10 @@
branch, tree = self.create3CommitsBranch()
tree.pull(tree.branch, overwrite=True, stop_revision='rev2')
tree.add_parent_tree_id('rev3')
- tree.commit('rev3a', rev_id='rev3a')
+ # XXX: AaronBentley 2010-08-06 bug=614404: a bzr username is
+ # required to generate the revision-id.
+ with override_environ(BZR_EMAIL='me@xxxxxxxxxxx'):
+ tree.commit('rev3a', rev_id='rev3a')
self.updateDBRevisions(branch, tree.branch, ['rev3', 'rev3a'])
job = RevisionsAddedJob.create(branch, 'rev1', 'rev3', '')
job.bzr_branch.lock_read()
@@ -542,9 +569,12 @@
tree.branch.nick = 'nicholas'
tree.lock_write()
self.addCleanup(tree.unlock)
- tree.commit(
- 'rev1', rev_id='rev1', timestamp=1000, timezone=0,
- committer='J. Random Hacker <jrandom@xxxxxxxxxxx>')
+ # XXX: AaronBentley 2010-08-06 bug=614404: a bzr username is
+ # required to generate the revision-id.
+ with override_environ(BZR_EMAIL='me@xxxxxxxxxxx'):
+ tree.commit(
+ 'rev1', rev_id='rev1', timestamp=1000, timezone=0,
+ committer='J. Random Hacker <jrandom@xxxxxxxxxxx>')
return branch, tree
def makeRevisionsAddedWithMergeCommit(self, authors=None,
@@ -558,20 +588,23 @@
self.useBzrBranches(direct_database=True)
branch, tree = self.create_branch_and_tree()
tree.branch.nick = 'nicholas'
- tree.commit('rev1')
- tree2 = tree.bzrdir.sprout('tree2').open_workingtree()
- tree2.commit('rev2a', rev_id='rev2a-id', committer='foo@')
- tree2.commit('rev3', rev_id='rev3-id',
- authors=['bar@', 'baz@xxxxxxxxxx'])
- tree.merge_from_branch(tree2.branch)
- tree3 = tree.bzrdir.sprout('tree3').open_workingtree()
- tree3.commit('rev2b', rev_id='rev2b-id', committer='qux@')
- tree.merge_from_branch(tree3.branch, force=True)
- if include_ghost:
- tree.add_parent_tree_id('rev2c-id')
- tree.commit('rev2d', rev_id='rev2d-id', timestamp=1000, timezone=0,
- committer='J. Random Hacker <jrandom@xxxxxxxxxxx>',
- authors=authors)
+ # XXX: AaronBentley 2010-08-06 bug=614404: a bzr username is
+ # required to generate the revision-id.
+ with override_environ(BZR_EMAIL='me@xxxxxxxxxxx'):
+ tree.commit('rev1')
+ tree2 = tree.bzrdir.sprout('tree2').open_workingtree()
+ tree2.commit('rev2a', rev_id='rev2a-id', committer='foo@')
+ tree2.commit('rev3', rev_id='rev3-id',
+ authors=['bar@', 'baz@xxxxxxxxxx'])
+ tree.merge_from_branch(tree2.branch)
+ tree3 = tree.bzrdir.sprout('tree3').open_workingtree()
+ tree3.commit('rev2b', rev_id='rev2b-id', committer='qux@')
+ tree.merge_from_branch(tree3.branch, force=True)
+ if include_ghost:
+ tree.add_parent_tree_id('rev2c-id')
+ tree.commit('rev2d', rev_id='rev2d-id', timestamp=1000, timezone=0,
+ committer='J. Random Hacker <jrandom@xxxxxxxxxxx>',
+ authors=authors)
return RevisionsAddedJob.create(branch, 'rev2d-id', 'rev2d-id', '')
def test_getMergedRevisionIDs(self):
@@ -817,17 +850,20 @@
first_revision = 'rev-1'
tree.bzrdir.root_transport.put_bytes('hello.txt', 'Hello World\n')
tree.add('hello.txt')
- tree.commit(
- rev_id=first_revision, message="Log message",
- committer="Joe Bloggs <joe@xxxxxxxxxxx>", timestamp=1000000000.0,
- timezone=0)
- tree.bzrdir.root_transport.put_bytes(
- 'hello.txt', 'Hello World\n\nFoo Bar\n')
- second_revision = 'rev-2'
- tree.commit(
- rev_id=second_revision, message="Extended contents",
- committer="Joe Bloggs <joe@xxxxxxxxxxx>", timestamp=1000100000.0,
- timezone=0)
+ # XXX: AaronBentley 2010-08-06 bug=614404: a bzr username is
+ # required to generate the revision-id.
+ with override_environ(BZR_EMAIL='me@xxxxxxxxxxx'):
+ tree.commit(
+ rev_id=first_revision, message="Log message",
+ committer="Joe Bloggs <joe@xxxxxxxxxxx>",
+ timestamp=1000000000.0, timezone=0)
+ tree.bzrdir.root_transport.put_bytes(
+ 'hello.txt', 'Hello World\n\nFoo Bar\n')
+ second_revision = 'rev-2'
+ tree.commit(
+ rev_id=second_revision, message="Extended contents",
+ committer="Joe Bloggs <joe@xxxxxxxxxxx>",
+ timestamp=1000100000.0, timezone=0)
transaction.commit()
self.layer.switchDbUser('branchscanner')
self.updateDBRevisions(db_branch, tree.branch)
@@ -874,9 +910,13 @@
self.useBzrBranches(direct_database=True)
db_branch, tree = self.create_branch_and_tree()
rev_id = 'rev-1'
- tree.commit(
- rev_id=rev_id, message=u"Non ASCII: \xe9",
- committer=u"Non ASCII: \xed", timestamp=1000000000.0, timezone=0)
+ # XXX: AaronBentley 2010-08-06 bug=614404: a bzr username is
+ # required to generate the revision-id.
+ with override_environ(BZR_EMAIL='me@xxxxxxxxxxx'):
+ tree.commit(
+ rev_id=rev_id, message=u"Non ASCII: \xe9",
+ committer=u"Non ASCII: \xed", timestamp=1000000000.0,
+ timezone=0)
transaction.commit()
self.layer.switchDbUser('branchscanner')
self.updateDBRevisions(db_branch, tree.branch)
@@ -986,7 +1026,10 @@
[self.tree.abspath(file_pair[0]) for file_pair in files])
if commit_message is None:
commit_message = self.factory.getUniqueString('commit')
- revision_id = self.tree.commit(commit_message)
+ # XXX: AaronBentley 2010-08-06 bug=614404: a bzr username is
+ # required to generate the revision-id.
+ with override_environ(BZR_EMAIL='me@xxxxxxxxxxx'):
+ revision_id = self.tree.commit(commit_message)
self.branch.last_scanned_id = revision_id
self.branch.last_mirrored_id = revision_id
return revision_id
=== modified file 'lib/lp/code/model/tests/test_branchmergeproposaljobs.py'
--- lib/lp/code/model/tests/test_branchmergeproposaljobs.py 2010-06-11 01:51:15 +0000
+++ lib/lp/code/model/tests/test_branchmergeproposaljobs.py 2010-08-17 04:46:45 +0000
@@ -3,6 +3,8 @@
"""Tests for branch merge proposal jobs."""
+from __future__ import with_statement
+
__metaclass__ = type
from datetime import datetime, timedelta
@@ -39,6 +41,7 @@
from lp.code.subscribers.branchmergeproposal import merge_proposal_modified
from lp.services.job.runner import JobRunner
from lp.services.job.model.job import Job
+from lp.services.osutils import override_environ
from lp.testing import TestCaseWithFactory
from lp.testing.mail_helpers import pop_notifications
@@ -104,7 +107,10 @@
def createProposalWithEmptyBranches(self):
target_branch, tree = self.create_branch_and_tree()
- tree.commit('test')
+ # XXX: AaronBentley 2010-08-06 bug=614404: a bzr username is
+ # required to generate the revision-id.
+ with override_environ(BZR_EMAIL='me@xxxxxxxxxxx'):
+ tree.commit('test')
source_branch = self.factory.makeProductBranch(
product=target_branch.product)
self.createBzrBranch(source_branch, tree.branch)
@@ -137,7 +143,10 @@
bmp = self.factory.makeBranchMergeProposal(
target_branch=self.factory.makePackageBranch())
tree = self.create_branch_and_tree(db_branch=bmp.target_branch)[1]
- tree.commit('Initial commit')
+ # XXX: AaronBentley 2010-08-06 bug=614404: a bzr username is
+ # required to generate the revision-id.
+ with override_environ(BZR_EMAIL='me@xxxxxxxxxxx'):
+ tree.commit('Initial commit')
self.createBzrBranch(bmp.source_branch, tree.branch)
self.factory.makeRevisionsForBranch(bmp.source_branch, count=1)
job = MergeProposalCreatedJob.create(bmp)
=== modified file 'lib/lp/code/model/tests/test_diff.py'
--- lib/lp/code/model/tests/test_diff.py 2010-08-02 02:13:52 +0000
+++ lib/lp/code/model/tests/test_diff.py 2010-08-17 04:46:45 +0000
@@ -3,6 +3,8 @@
"""Tests for Diff, etc."""
+from __future__ import with_statement
+
__metaclass__ = type
@@ -26,6 +28,7 @@
from lp.code.interfaces.diff import (
IDiff, IPreviewDiff, IStaticDiff, IStaticDiffSource)
from lp.testing import login, login_person, TestCaseWithFactory
+from lp.services.osutils import override_environ
class RecordLister(logging.Handler):
@@ -285,7 +288,10 @@
"""Ensure that acquire returns the existing StaticDiff."""
self.useBzrBranches(direct_database=True)
branch, tree = self.create_branch_and_tree()
- tree.commit('First commit', rev_id='rev1')
+ # XXX: AaronBentley 2010-08-06 bug=614404: a bzr username is
+ # required to generate the revision-id.
+ with override_environ(BZR_EMAIL='me@xxxxxxxxxxx'):
+ tree.commit('First commit', rev_id='rev1')
diff1 = StaticDiff.acquire('null:', 'rev1', tree.branch.repository)
diff2 = StaticDiff.acquire('null:', 'rev1', tree.branch.repository)
self.assertIs(diff1, diff2)
@@ -294,7 +300,10 @@
"""The existing object is used even if the repository is different."""
self.useBzrBranches(direct_database=True)
branch1, tree1 = self.create_branch_and_tree('tree1')
- tree1.commit('First commit', rev_id='rev1')
+ # XXX: AaronBentley 2010-08-06 bug=614404: a bzr username is
+ # required to generate the revision-id.
+ with override_environ(BZR_EMAIL='me@xxxxxxxxxxx'):
+ tree1.commit('First commit', rev_id='rev1')
branch2, tree2 = self.create_branch_and_tree('tree2')
tree2.pull(tree1.branch)
diff1 = StaticDiff.acquire('null:', 'rev1', tree1.branch.repository)
@@ -305,8 +314,11 @@
"""A new object is created if there is no existant matching object."""
self.useBzrBranches(direct_database=True)
branch, tree = self.create_branch_and_tree()
- tree.commit('First commit', rev_id='rev1')
- tree.commit('Next commit', rev_id='rev2')
+ # XXX: AaronBentley 2010-08-06 bug=614404: a bzr username is
+ # required to generate the revision-id.
+ with override_environ(BZR_EMAIL='me@xxxxxxxxxxx'):
+ tree.commit('First commit', rev_id='rev1')
+ tree.commit('Next commit', rev_id='rev2')
diff1 = StaticDiff.acquire('null:', 'rev1', tree.branch.repository)
diff2 = StaticDiff.acquire('rev1', 'rev2', tree.branch.repository)
self.assertIsNot(diff1, diff2)
=== modified file 'lib/lp/code/scripts/tests/test_scan_branches.py'
--- lib/lp/code/scripts/tests/test_scan_branches.py 2010-06-07 09:11:06 +0000
+++ lib/lp/code/scripts/tests/test_scan_branches.py 2010-08-17 04:46:45 +0000
@@ -6,6 +6,8 @@
"""Test the scan_branches script."""
+from __future__ import with_statement
+
from storm.locals import Store
import transaction
@@ -17,6 +19,7 @@
CodeReviewNotificationLevel)
from lp.code.model.branchjob import BranchJob, BranchJobType, BranchScanJob
from lp.services.job.model.job import Job, JobStatus
+from lp.services.osutils import override_environ
class TestScanBranches(TestCaseWithFactory):
@@ -27,9 +30,12 @@
def make_branch_with_commits_and_scan_job(self, db_branch):
"""Create a branch from a db_branch, make commits and a scan job."""
target, target_tree = self.create_branch_and_tree(db_branch=db_branch)
- target_tree.commit('First commit', rev_id='rev1')
- target_tree.commit('Second commit', rev_id='rev2')
- target_tree.commit('Third commit', rev_id='rev3')
+ # XXX: AaronBentley 2010-08-06 bug=614404: a bzr username is
+ # required to generate the revision-id.
+ with override_environ(BZR_EMAIL='me@xxxxxxxxxxx'):
+ target_tree.commit('First commit', rev_id='rev1')
+ target_tree.commit('Second commit', rev_id='rev2')
+ target_tree.commit('Third commit', rev_id='rev3')
BranchScanJob.create(db_branch)
transaction.commit()
=== modified file 'lib/lp/code/scripts/tests/test_sendbranchmail.py'
--- lib/lp/code/scripts/tests/test_sendbranchmail.py 2010-06-07 09:11:06 +0000
+++ lib/lp/code/scripts/tests/test_sendbranchmail.py 2010-08-17 04:46:45 +0000
@@ -5,6 +5,8 @@
"""Test the sendbranchmail script"""
+from __future__ import with_statement
+
import unittest
import transaction
@@ -16,6 +18,7 @@
from lp.code.model.branchjob import (
RevisionMailJob, RevisionsAddedJob)
from lp.testing import TestCaseWithFactory
+from lp.services.osutils import override_environ
class TestSendbranchmail(TestCaseWithFactory):
@@ -33,7 +36,10 @@
transport = tree.bzrdir.root_transport
transport.put_bytes('foo', 'bar')
tree.add('foo')
- tree.commit('Added foo.', rev_id='rev1')
+ # XXX: AaronBentley 2010-08-06 bug=614404: a bzr username is
+ # required to generate the revision-id.
+ with override_environ(BZR_EMAIL='me@xxxxxxxxxxx'):
+ tree.commit('Added foo.', rev_id='rev1')
return branch, tree
def test_sendbranchmail(self):
@@ -73,7 +79,10 @@
self.useBzrBranches()
branch, tree = self.createBranch()
tree.bzrdir.root_transport.put_bytes('foo', 'baz')
- tree.commit('Added foo.', rev_id='rev2')
+ # XXX: AaronBentley 2010-08-06 bug=614404: a bzr username is
+ # required to generate the revision-id.
+ with override_environ(BZR_EMAIL='me@xxxxxxxxxxx'):
+ tree.commit('Added foo.', rev_id='rev2')
RevisionsAddedJob.create(
branch, 'rev1', 'rev2', 'from@xxxxxxxxxxx')
transaction.commit()
=== modified file 'lib/lp/codehosting/codeimport/tests/test_worker.py'
--- lib/lp/codehosting/codeimport/tests/test_worker.py 2010-08-02 23:01:15 +0000
+++ lib/lp/codehosting/codeimport/tests/test_worker.py 2010-08-17 04:46:45 +0000
@@ -952,7 +952,7 @@
t = get_transport(self.get_url('.'))
t.mkdir('reference')
a_bzrdir = BzrDir.create(self.get_url('reference'))
- BranchReferenceFormat().initialize(a_bzrdir, branch)
+ BranchReferenceFormat().initialize(a_bzrdir, target_branch=branch)
return a_bzrdir.root_transport.base
def test_reject_branch_reference(self):
=== modified file 'lib/lp/codehosting/codeimport/uifactory.py'
--- lib/lp/codehosting/codeimport/uifactory.py 2009-08-24 16:27:33 +0000
+++ lib/lp/codehosting/codeimport/uifactory.py 2010-08-17 04:46:45 +0000
@@ -75,6 +75,24 @@
# There's no point showing a progress bar in a flat log.
return ''
+ def _render_line(self):
+ bar_string = self._render_bar()
+ if self._last_task:
+ task_part, counter_part = self._format_task(self._last_task)
+ else:
+ task_part = counter_part = ''
+ if self._last_task and not self._last_task.show_transport_activity:
+ trans = ''
+ else:
+ trans = self._last_transport_msg
+ # the bar separates the transport activity from the message, so even
+ # if there's no bar or spinner, we must show something if both those
+ # fields are present
+ if (task_part and trans) and not bar_string:
+ bar_string = ' | '
+ s = trans + bar_string + task_part + counter_part
+ return s
+
def _format_transport_msg(self, scheme, dir_char, rate):
# We just report the amount of data transferred.
return '%s bytes transferred' % self._bytes_since_update
=== modified file 'lib/lp/codehosting/puller/worker.py'
--- lib/lp/codehosting/puller/worker.py 2010-04-21 01:56:51 +0000
+++ lib/lp/codehosting/puller/worker.py 2010-08-17 04:46:45 +0000
@@ -503,7 +503,7 @@
def get_boolean(self, prompt):
"""If we're asked to break a lock like a stale lock of ours, say yes.
"""
- assert prompt.startswith('Break lock'), (
+ assert prompt.startswith('Break '), (
"Didn't expect prompt %r" % (prompt,))
branch_id = self.puller_worker_protocol.branch_id
if get_lock_id_for_branch_id(branch_id) in prompt:
=== modified file 'lib/lp/codehosting/scanner/tests/test_buglinks.py'
--- lib/lp/codehosting/scanner/tests/test_buglinks.py 2010-08-02 02:13:52 +0000
+++ lib/lp/codehosting/scanner/tests/test_buglinks.py 2010-08-17 04:46:45 +0000
@@ -3,6 +3,8 @@
"""Tests for creating BugBranch items based on Bazaar revisions."""
+from __future__ import with_statement
+
__metaclass__ = type
import unittest
@@ -22,6 +24,7 @@
from lp.codehosting.scanner.tests.test_bzrsync import BzrSyncTestCase
from lp.registry.interfaces.pocket import PackagePublishingPocket
from lp.testing import TestCase, TestCaseWithFactory
+from lp.services.osutils import override_environ
class RevisionPropertyParsing(TestCase):
@@ -189,28 +192,31 @@
"""Don't add BugBranches based on non-mainline revisions."""
# Make the base revision.
author = self.factory.getUniqueString()
- self.bzr_tree.commit(
- u'common parent', committer=author, rev_id='r1',
- allow_pointless=True)
-
- # Branch from the base revision.
- new_tree = self.make_branch_and_tree('bzr_branch_merged')
- new_tree.pull(self.bzr_branch)
-
- # Commit to both branches
- self.bzr_tree.commit(
- u'commit one', committer=author, rev_id='r2',
- allow_pointless=True)
- new_tree.commit(
- u'commit two', committer=author, rev_id='r1.1.1',
- allow_pointless=True,
- revprops={'bugs': '%s fixed' % self.getBugURL(self.bug1)})
-
- # Merge and commit.
- self.bzr_tree.merge_from_branch(new_tree.branch)
- self.bzr_tree.commit(
- u'merge', committer=author, rev_id='r3',
- allow_pointless=True)
+ # XXX: AaronBentley 2010-08-06 bug=614404: a bzr username is
+ # required to generate the revision-id.
+ with override_environ(BZR_EMAIL='me@xxxxxxxxxxx'):
+ self.bzr_tree.commit(
+ u'common parent', committer=author, rev_id='r1',
+ allow_pointless=True)
+
+ # Branch from the base revision.
+ new_tree = self.make_branch_and_tree('bzr_branch_merged')
+ new_tree.pull(self.bzr_branch)
+
+ # Commit to both branches
+ self.bzr_tree.commit(
+ u'commit one', committer=author, rev_id='r2',
+ allow_pointless=True)
+ new_tree.commit(
+ u'commit two', committer=author, rev_id='r1.1.1',
+ allow_pointless=True,
+ revprops={'bugs': '%s fixed' % self.getBugURL(self.bug1)})
+
+ # Merge and commit.
+ self.bzr_tree.merge_from_branch(new_tree.branch)
+ self.bzr_tree.commit(
+ u'merge', committer=author, rev_id='r3',
+ allow_pointless=True)
self.syncBazaarBranchToDatabase(self.bzr_branch, self.db_branch)
self.assertEqual(
@@ -251,8 +257,12 @@
bug = self.factory.makeBug()
self.layer.txn.commit()
LaunchpadZopelessLayer.switchDbUser(config.branchscanner.dbuser)
- revision_id = tree.commit('fix revision',
- revprops={'bugs': 'https://launchpad.net/bugs/%d fixed' % bug.id})
+ # XXX: AaronBentley 2010-08-06 bug=614404: a bzr username is
+ # required to generate the revision-id.
+ with override_environ(BZR_EMAIL='me@xxxxxxxxxxx'):
+ revision_id = tree.commit('fix revision',
+ revprops={
+ 'bugs': 'https://launchpad.net/bugs/%d fixed' % bug.id})
bzr_revision = tree.branch.repository.get_revision(revision_id)
revno = 1
revision_set = getUtility(IRevisionSet)
=== modified file 'lib/lp/codehosting/scanner/tests/test_bzrsync.py'
--- lib/lp/codehosting/scanner/tests/test_bzrsync.py 2010-07-14 14:48:46 +0000
+++ lib/lp/codehosting/scanner/tests/test_bzrsync.py 2010-08-17 04:46:45 +0000
@@ -5,6 +5,8 @@
# pylint: disable-msg=W0141
+from __future__ import with_statement
+
import datetime
import os
import random
@@ -32,6 +34,7 @@
from lp.codehosting.scanner.bzrsync import BzrSync
from lp.testing import TestCaseWithFactory
from canonical.testing import LaunchpadZopelessLayer
+from lp.services.osutils import override_environ
def run_as_db_user(username):
@@ -160,10 +163,13 @@
committer = self.factory.getUniqueString()
if extra_parents is not None:
self.bzr_tree.add_pending_merge(*extra_parents)
- return self.bzr_tree.commit(
- message, committer=committer, rev_id=rev_id,
- timestamp=timestamp, timezone=timezone, allow_pointless=True,
- revprops=revprops)
+ # XXX: AaronBentley 2010-08-06 bug=614404: a bzr username is
+ # required to generate the revision-id.
+ with override_environ(BZR_EMAIL='me@xxxxxxxxxxx'):
+ return self.bzr_tree.commit(
+ message, committer=committer, rev_id=rev_id,
+ timestamp=timestamp, timezone=timezone, allow_pointless=True,
+ revprops=revprops)
def uncommitRevision(self):
branch = self.bzr_tree.branch
@@ -207,21 +213,24 @@
db_branch = self.makeDatabaseBranch()
db_branch, trunk_tree = self.create_branch_and_tree(
db_branch=db_branch)
- trunk_tree.commit(u'base revision', rev_id=base_rev_id)
-
- # Branch from the base revision.
- new_db_branch = self.makeDatabaseBranch(product=db_branch.product)
- new_db_branch, branch_tree = self.create_branch_and_tree(
- db_branch=new_db_branch)
- branch_tree.pull(trunk_tree.branch)
-
- # Commit to both branches.
- trunk_tree.commit(u'trunk revision', rev_id=trunk_rev_id)
- branch_tree.commit(u'branch revision', rev_id=branch_rev_id)
-
- # Merge branch into trunk.
- trunk_tree.merge_from_branch(branch_tree.branch)
- trunk_tree.commit(u'merge revision', rev_id=merge_rev_id)
+ # XXX: AaronBentley 2010-08-06 bug=614404: a bzr username is
+ # required to generate the revision-id.
+ with override_environ(BZR_EMAIL='me@xxxxxxxxxxx'):
+ trunk_tree.commit(u'base revision', rev_id=base_rev_id)
+
+ # Branch from the base revision.
+ new_db_branch = self.makeDatabaseBranch(product=db_branch.product)
+ new_db_branch, branch_tree = self.create_branch_and_tree(
+ db_branch=new_db_branch)
+ branch_tree.pull(trunk_tree.branch)
+
+ # Commit to both branches.
+ trunk_tree.commit(u'trunk revision', rev_id=trunk_rev_id)
+ branch_tree.commit(u'branch revision', rev_id=branch_rev_id)
+
+ # Merge branch into trunk.
+ trunk_tree.merge_from_branch(branch_tree.branch)
+ trunk_tree.commit(u'merge revision', rev_id=merge_rev_id)
LaunchpadZopelessLayer.txn.commit()
LaunchpadZopelessLayer.switchDbUser(config.branchscanner.dbuser)
=== modified file 'lib/lp/codehosting/scanner/tests/test_mergedetection.py'
--- lib/lp/codehosting/scanner/tests/test_mergedetection.py 2010-04-12 17:02:16 +0000
+++ lib/lp/codehosting/scanner/tests/test_mergedetection.py 2010-08-17 04:46:45 +0000
@@ -3,6 +3,8 @@
"""Tests for the scanner's merge detection."""
+from __future__ import with_statement
+
__metaclass__ = type
import logging
@@ -27,6 +29,7 @@
BranchMergeProposalJob, BranchMergeProposalJobFactory,
BranchMergeProposalJobType)
from lp.code.interfaces.branchlookup import IBranchLookup
+from lp.services.osutils import override_environ
from lp.testing import TestCase, TestCaseWithFactory
from lp.testing.mail_helpers import pop_notifications
@@ -129,7 +132,10 @@
proposal, db_trunk, db_branch, branch_tree = (
self._createBranchesAndProposal())
- branch_tree.commit(u'another revision', rev_id='another-rev')
+ # XXX: AaronBentley 2010-08-06 bug=614404: a bzr username is
+ # required to generate the revision-id.
+ with override_environ(BZR_EMAIL='me@xxxxxxxxxxx'):
+ branch_tree.commit(u'another revision', rev_id='another-rev')
current_proposal_status = proposal.queue_status
self.assertNotEqual(
current_proposal_status,
@@ -147,7 +153,10 @@
proposal, db_trunk, db_branch, branch_tree = (
self._createBranchesAndProposal())
- branch_tree.commit(u'another revision', rev_id='another-rev')
+ # XXX: AaronBentley 2010-08-06 bug=614404: a bzr username is
+ # required to generate the revision-id.
+ with override_environ(BZR_EMAIL='me@xxxxxxxxxxx'):
+ branch_tree.commit(u'another revision', rev_id='another-rev')
current_proposal_status = proposal.queue_status
self.assertNotEqual(
current_proposal_status,
=== modified file 'lib/lp/codehosting/tests/test_acceptance.py'
--- lib/lp/codehosting/tests/test_acceptance.py 2010-08-05 11:56:34 +0000
+++ lib/lp/codehosting/tests/test_acceptance.py 2010-08-17 04:46:45 +0000
@@ -242,10 +242,7 @@
creator_id, '/~%s/%s/%s' % (user, product, branch))
branch_url = 'file://' + os.path.abspath(
os.path.join(branch_root, branch_id_to_path(branch_id)))
- self.runInChdir(
- self.local_branch_path,
- self.run_bzr, ['push', '--create-prefix', branch_url],
- retcode=None)
+ self.push(self.local_branch_path, branch_url, ['--create-prefix'])
return branch_url
=== modified file 'lib/lp/codehosting/tests/test_branchdistro.py'
--- lib/lp/codehosting/tests/test_branchdistro.py 2010-04-23 05:49:08 +0000
+++ lib/lp/codehosting/tests/test_branchdistro.py 2010-08-17 04:46:45 +0000
@@ -4,6 +4,8 @@
"""Tests for making new source package branches just after a distro release.
"""
+from __future__ import with_statement
+
__metaclass__ = type
import os
@@ -32,6 +34,7 @@
from lp.codehosting.vfs import branch_id_to_path
from lp.registry.interfaces.pocket import PackagePublishingPocket
from lp.testing import TestCaseWithFactory
+from lp.services.osutils import override_environ
# We say "RELEASE" often enough to not want to say "PackagePublishingPocket."
@@ -66,7 +69,10 @@
old_branch = FakeBranch(1)
self.get_transport(old_branch.unique_name).create_prefix()
tree = self.make_branch_and_tree(old_branch.unique_name)
- tree.commit(message='.')
+ # XXX: AaronBentley 2010-08-06 bug=614404: a bzr username is
+ # required to generate the revision-id.
+ with override_environ(BZR_EMAIL='me@xxxxxxxxxxx'):
+ tree.commit(message='.')
new_branch = FakeBranch(2)
@@ -119,7 +125,10 @@
_, tree = self.create_branch_and_tree(
tree_location=self.factory.getUniqueString(), db_branch=db_branch)
- tree.commit('')
+ # XXX: AaronBentley 2010-08-06 bug=614404: a bzr username is
+ # required to generate the revision-id.
+ with override_environ(BZR_EMAIL='me@xxxxxxxxxxx'):
+ tree.commit('')
return db_branch
@@ -484,8 +493,11 @@
brancher.makeOneNewBranch(db_branch)
url = 'lp-internal:///' + db_branch.unique_name
old_bzr_branch = Branch.open(url)
- old_bzr_branch.create_checkout(
- self.factory.getUniqueString()).commit('')
+ # XXX: AaronBentley 2010-08-06 bug=614404: a bzr username is
+ # required to generate the revision-id.
+ with override_environ(BZR_EMAIL='me@xxxxxxxxxxx'):
+ old_bzr_branch.create_checkout(
+ self.factory.getUniqueString()).commit('')
ok = brancher.checkOneBranch(db_branch)
self.assertLogMessages([
'^WARNING Repository at lp-internal:///.*/.*/.*/.* has 1 '
=== modified file 'lib/lp/codehosting/tests/test_bzrutils.py'
--- lib/lp/codehosting/tests/test_bzrutils.py 2010-04-23 01:47:30 +0000
+++ lib/lp/codehosting/tests/test_bzrutils.py 2010-08-17 04:46:45 +0000
@@ -14,7 +14,7 @@
from bzrlib.branch import Branch, BranchReferenceFormat
from bzrlib.bzrdir import BzrDir, format_registry
from bzrlib.remote import RemoteBranch
-from bzrlib.smart import server
+from bzrlib.tests import test_server
from bzrlib.tests import (
multiply_tests, TestCase, TestCaseWithTransport, TestLoader,
TestNotApplicable)
@@ -191,7 +191,7 @@
# of the branch, repo and bzrdir, even if the branch is a
# RemoteBranch.
vfs_branch = self.make_branch('.')
- smart_server = server.SmartTCPServer_for_testing()
+ smart_server = test_server.SmartTCPServer_for_testing()
smart_server.start_server(self.get_vfs_only_server())
self.addCleanup(smart_server.stop_server)
remote_branch = Branch.open(smart_server.get_url())
=== modified file 'lib/lp/codehosting/tests/test_jobs.py'
--- lib/lp/codehosting/tests/test_jobs.py 2010-05-27 02:04:21 +0000
+++ lib/lp/codehosting/tests/test_jobs.py 2010-08-17 04:46:45 +0000
@@ -3,6 +3,7 @@
"""Tests for Job-running facilities."""
+from __future__ import with_statement
from unittest import TestLoader
@@ -15,6 +16,7 @@
from lp.code.model.branchjob import RevisionMailJob
from lp.code.model.diff import StaticDiff
from lp.services.job.runner import JobRunner
+from lp.services.osutils import override_environ
from lp.testing import TestCaseWithFactory
@@ -34,7 +36,10 @@
tree_transport = tree.bzrdir.root_transport
tree_transport.put_bytes("hello.txt", "Hello World\n")
tree.add('hello.txt')
- to_revision_id = tree.commit('rev1', timestamp=1e9, timezone=0)
+ # XXX: AaronBentley 2010-08-06 bug=614404: a bzr username is
+ # required to generate the revision-id.
+ with override_environ(BZR_EMAIL='me@xxxxxxxxxxx'):
+ to_revision_id = tree.commit('rev1', timestamp=1e9, timezone=0)
job = RevisionMailJob.create(
branch, 1, 'from@xxxxxxxxxxx', 'body', True, 'subject')
LaunchpadZopelessLayer.txn.commit()
=== modified file 'lib/lp/codehosting/vfs/tests/test_transport.py'
--- lib/lp/codehosting/vfs/tests/test_transport.py 2010-04-19 07:05:57 +0000
+++ lib/lp/codehosting/vfs/tests/test_transport.py 2010-08-17 04:46:45 +0000
@@ -43,6 +43,9 @@
BlockingProxy(branchfs), LocalTransport(local_path_to_url('.')))
self._chroot_servers = []
+ def get_bogus_url(self):
+ return self._scheme + 'bogus'
+
def _transportFactory(self, url):
"""See `LaunchpadInternalServer._transportFactory`.
=== modified file 'lib/lp/services/osutils.py'
--- lib/lp/services/osutils.py 2010-03-18 19:18:34 +0000
+++ lib/lp/services/osutils.py 2010-08-17 04:46:45 +0000
@@ -5,12 +5,14 @@
__metaclass__ = type
__all__ = [
+ 'override_environ',
'remove_tree',
'kill_by_pidfile',
'remove_if_exists',
'two_stage_kill',
]
+from contextlib import contextmanager
import os.path
import shutil
@@ -26,3 +28,33 @@
"""Remove the tree at 'path' from disk."""
if os.path.exists(path):
shutil.rmtree(path)
+
+
+def set_environ(new_values):
+ """Set the environment variables as specified by new_values.
+
+ :return: a dict of the old values
+ """
+ old_values = {}
+ for name, value in new_values.iteritems():
+ old_values[name] = os.environ.get(name)
+ if value is None:
+ if old_values[name] is not None:
+ del os.environ[name]
+ else:
+ os.environ[name] = value
+ return old_values
+
+
+@contextmanager
+def override_environ(**kwargs):
+ """Override environment variables with the kwarg values.
+
+ If a value is None, the environment variable is deleted. Variables are
+ restored to their previous state when exiting the context.
+ """
+ old_values = set_environ(kwargs)
+ try:
+ yield
+ finally:
+ set_environ(old_values)
=== modified file 'lib/lp/testing/__init__.py'
--- lib/lp/testing/__init__.py 2010-08-02 19:52:59 +0000
+++ lib/lp/testing/__init__.py 2010-08-17 04:46:45 +0000
@@ -117,6 +117,7 @@
launchpadlib_credentials_for, launchpadlib_for, oauth_access_token_for)
from lp.testing.matchers import Provides
from lp.testing.fixture import ZopeEventHandlerFixture
+from lp.services.osutils import override_environ
# zope.exception demands more of frame objects than twisted.python.failure
# provides in its fake frames. This is enough to make it work with them
@@ -577,18 +578,11 @@
return os.path.join(base, branch_id_to_path(branch.id))
def useTempBzrHome(self):
- # XXX: Extract the temporary environment blatting into a generic
- # helper function.
self.useTempDir()
# Avoid leaking local user configuration into tests.
- old_bzr_home = os.environ.get('BZR_HOME')
- def restore_bzr_home():
- if old_bzr_home is None:
- del os.environ['BZR_HOME']
- else:
- os.environ['BZR_HOME'] = old_bzr_home
- os.environ['BZR_HOME'] = os.getcwd()
- self.addCleanup(restore_bzr_home)
+ self.useContext(override_environ(
+ BZR_HOME=os.getcwd(), BZR_EMAIL=None, EMAIL=None,
+ ))
def useBzrBranches(self, direct_database=False):
"""Prepare for using bzr branches.
=== modified file 'lib/lp/translations/scripts/translations_to_branch.py'
--- lib/lp/translations/scripts/translations_to_branch.py 2010-06-16 07:22:57 +0000
+++ lib/lp/translations/scripts/translations_to_branch.py 2010-08-17 04:46:45 +0000
@@ -103,22 +103,16 @@
# possible again to commit to these branches at some point.
# When that happens, remove this workaround and just call
# _makeDirectBranchCommit directly.
- committer = self._makeDirectBranchCommit(db_branch)
- if not db_branch.stacked_on:
- # The normal case.
- return committer
-
- self.logger.info("Unstacking branch to work around bug 375013.")
- try:
- committer.bzrbranch.set_stacked_on_url(None)
- finally:
- committer.unlock()
- self.logger.info("Done unstacking branch.")
-
- # This may have taken a while, so commit for good
- # manners.
- if self.txn:
- self.txn.commit()
+ if db_branch.stacked_on:
+ bzrbranch = db_branch.getBzrBranch()
+ self.logger.info("Unstacking branch to work around bug 375013.")
+ bzrbranch.set_stacked_on_url(None)
+ self.logger.info("Done unstacking branch.")
+
+ # This may have taken a while, so commit for good
+ # manners.
+ if self.txn:
+ self.txn.commit()
return self._makeDirectBranchCommit(db_branch)
=== modified file 'lib/lp/translations/tests/test_rosetta_branches_script.py'
--- lib/lp/translations/tests/test_rosetta_branches_script.py 2010-04-23 09:36:47 +0000
+++ lib/lp/translations/tests/test_rosetta_branches_script.py 2010-08-17 04:46:45 +0000
@@ -7,6 +7,8 @@
provisions to handle Bazaar branches.
"""
+from __future__ import with_statement
+
__metaclass__ = type
from unittest import TestLoader
@@ -23,6 +25,7 @@
ITranslationImportQueue, RosettaImportStatus)
from canonical.launchpad.scripts.tests import run_script
from lp.testing import TestCaseWithFactory
+from lp.services.osutils import override_environ
from canonical.launchpad.webapp.errorlog import globalErrorUtility
class TestRosettaBranchesScript(TestCaseWithFactory):
@@ -43,7 +46,10 @@
branch, tree = self.create_branch_and_tree()
tree.bzrdir.root_transport.put_bytes(pot_path, pot_content)
tree.add(pot_path)
- revision_id = tree.commit("first commit")
+ # XXX: AaronBentley 2010-08-06 bug=614404: a bzr username is
+ # required to generate the revision-id.
+ with override_environ(BZR_EMAIL='me@xxxxxxxxxxx'):
+ revision_id = tree.commit("first commit")
branch.last_scanned_id = revision_id
branch.last_mirrored_id = revision_id
series = self.factory.makeProductSeries()
=== modified file 'utilities/sourcedeps.conf'
--- utilities/sourcedeps.conf 2010-08-16 15:00:28 +0000
+++ utilities/sourcedeps.conf 2010-08-17 04:46:45 +0000
@@ -1,7 +1,7 @@
bzr-builder lp:~launchpad-pqm/bzr-builder/trunk;revno=65
bzr-git lp:~launchpad-pqm/bzr-git/devel;revno=257
-bzr-hg lp:~launchpad-pqm/bzr-hg/devel;revno=281
-bzr-loom lp:~launchpad-pqm/bzr-loom/trunk;revno=47
+bzr-hg lp:~launchpad-pqm/bzr-hg/devel;revno=282
+bzr-loom lp:~launchpad-pqm/bzr-loom/trunk;revno=48
bzr-svn lp:~launchpad-pqm/bzr-svn/devel;revno=2709
cscvs lp:~launchpad-pqm/launchpad-cscvs/devel;revno=432
dulwich lp:~launchpad-pqm/dulwich/devel;revno=423
=== modified file 'versions.cfg'
--- versions.cfg 2010-08-06 16:52:08 +0000
+++ versions.cfg 2010-08-17 04:46:45 +0000
@@ -5,7 +5,7 @@
# Alphabetical, case-insensitive, please! :-)
ampoule = 0.2.0
-bzr = 2.1.0
+bzr = 2.2.0
chameleon.core = 1.0b35
chameleon.zpt = 1.0b17
ClientForm = 0.2.10