Detailed tests of bzr.py ======================= .. :doctest: .. :setup: zest.releaser.tests.functional.setup .. :teardown: zest.releaser.tests.functional.teardown Some initial imports: >>> from zest.releaser import bzr >>> from zest.releaser.utils import execute_command >>> import os Project name ------------ The prepared bzr project has a setup.py, so the name in there is used: >>> os.chdir(bzrsourcedir) >>> checkout = bzr.Bzr() >>> checkout.name 'tha.example' When the setup.py doesn't exist or doesn't return a proper name, we fall back to the directory name. >>> orig = checkout.get_setup_py_name >>> checkout.get_setup_py_name= lambda: None # Hack >>> checkout.name 'tha.example-bzr' >>> checkout.get_setup_py_name = orig # Restore hack Diff and commit --------------- Make a change: >>> setup_py = os.path.join(bzrsourcedir, 'setup.py') >>> dont_care = open(setup_py, 'a').write('\na = 2\n') >>> cmd = checkout.cmd_diff() >>> cmd 'bzr diff' >>> print(execute_command(cmd)) === modified file 'setup.py' --- setup.py ... +++ setup.py ... @@ -36,3 +36,5 @@ 'console_scripts': [ ]}, ) + +a = 2 Commit it: >>> cmd = checkout.cmd_commit('small tweak') >>> cmd 'bzr commit -v -m "small tweak"' >>> print(execute_command(cmd)) RED Committing to: TESTTEMP/tha.example-bzr/ RED modified setup.py RED Committed revision 2. Note the red color: bzr prints everything to stderr... Tags ---- Originally there are no tags (the default 'tip' tag is filtered out): >>> checkout.available_tags() [] Create a tag and it will show up: >>> cmd = checkout.cmd_create_tag('0.1') >>> cmd 'bzr tag 0.1' >>> dont_care = execute_command(cmd) >>> checkout.available_tags() ['0.1'] A specific tag url is important for subversion, but nonsensical for bazaar. We just return the version as-is: >>> checkout.tag_url('holadijee') 'holadijee' Make and commit a small change: >>> dont_care = open(setup_py, 'a').write('\nb = 3\n') >>> cmd = checkout.cmd_commit('small tweak') >>> print(execute_command(cmd)) RED Committing to: TESTTEMP/tha.example-bzr/ RED modified setup.py RED Committed revision 3. Now we can request the changes since a specific tag: >>> cmd = checkout.cmd_diff_last_commit_against_tag('0.1') >>> cmd 'bzr diff -r tag:0.1..-1' >>> print(execute_command(cmd)) === modified file 'setup.py' --- setup.py ... +++ setup.py ... @@ -38,3 +38,5 @@ ) a = 2 + +b = 3 Making a tag checkout --------------------- Some bzr versions cannot checkout in an existing directory, so contrary svn we will not create an empty tempdir before doing a checkout. The tag checkout command makes a checkout in a fresh dir: >>> checkout.checkout_from_tag('0.1') At the end of the command we are in the created directory. The checkout is done directly in that temporary directory, so not in a newly created subdirectory of it: >>> os.getcwd() '.../tha.example-0.1-...' >>> sorted(os.listdir('.')) ['.bzr', '.bzrignore', 'CHANGES.txt', ...] Pushing changes --------------- For bzr, committing is normally enough. We assume you've set it up that way, though you might not have done so. There's no handy way to find out, though. >>> checkout.push_commands() []