[Pkg-bazaar-commits] r112 ./bzr-builddeb/people/jdw/merge_upstream: Add some more tests of merge_upstream.
James Westby
jw+debian at jameswestby.net
Fri Jun 22 16:53:47 UTC 2007
------------------------------------------------------------
revno: 112
committer: James Westby <jw+debian at jameswestby.net>
branch nick: merge-upstream.siretart
timestamp: Fri 2007-06-22 16:43:18 +0100
message:
Add some more tests of merge_upstream.
* Test that the history is as expected, including the automatic commit
message.
* Add Reinhard to copyright.
* Add license header to merge_upstream.py.
modified:
__init__.py
debian/copyright
merge_upstream.py
tests/test_merge_upstream.py
-------------- next part --------------
=== modified file '__init__.py'
--- a/__init__.py 2007-06-21 22:55:10 +0000
+++ b/__init__.py 2007-06-22 15:43:18 +0000
@@ -1,6 +1,7 @@
# __init__.py -- The plugin for bzr
# Copyright (C) 2005 Jamie Wilkinson <jaq at debian.org>
# 2006, 2007 James Westby <jw+debian at jameswestby.net>
+# 2007 Reinhard Tartler <siretart at tauware.de>
#
# This file is part of bzr-builddeb.
#
=== modified file 'debian/copyright'
--- a/debian/copyright 2006-09-17 15:21:20 +0000
+++ b/debian/copyright 2007-06-22 15:43:18 +0000
@@ -7,7 +7,8 @@
Upstream Author: James Westby <jw+debian at jameswestby.net>
Copyright: 2005 Jamie Wilkinson <jaq at debian.org>
- 2006 James Westby <jw+debian at jameswestby.net>
+ 2006, 2007 James Westby <jw+debian at jameswestby.net>
+ 2007 Reinhard Tartler <siretart at tauware.de>
License:
=== modified file 'merge_upstream.py'
--- a/merge_upstream.py 2007-06-21 22:42:20 +0000
+++ b/merge_upstream.py 2007-06-22 15:43:18 +0000
@@ -1,3 +1,26 @@
+# merge_upstream.py -- Merge new upstream versions of packages.
+# Copyright (C) 2007 Reinhard Tartler <siretart at tauware.de>
+# 2007 James Westby <jw+debian at jameswestby.net>
+#
+# This file is part of bzr-builddeb.
+#
+# bzr-builddeb is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# bzr-builddeb is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with bzr-builddeb; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+#
+
+import os
+
from bzrlib.plugins.bzrtools.upstream_import import import_tar
def merge_upstream(tree, source, old_revision):
@@ -9,6 +32,6 @@
import_tar(tree, tar_input)
tree.set_parent_ids([rev_id])
tree.branch.set_last_revision_info(revno, rev_id)
- tree.commit('import upstream from %s' % file)
+ tree.commit('import upstream from %s' % os.path.basename(source))
tree.merge_from_branch(tree.branch, to_revision=current_revision)
=== modified file 'tests/test_merge_upstream.py'
--- a/tests/test_merge_upstream.py 2007-06-21 22:42:20 +0000
+++ b/tests/test_merge_upstream.py 2007-06-22 15:43:18 +0000
@@ -50,7 +50,7 @@
# create the original upstream import
self.build_tree(['README', 'CHANGELOG'])
wt.add(['README', 'CHANGELOG'], ['README-id', 'CHANGELOG-id'])
- wt.commit('upstream version 1')
+ wt.commit('upstream version 1', rev_id='upstream-1')
old_upstream_revision = wt.branch.last_revision()
# create the debian branch on top
self.build_tree(['debian/', 'debian/changelog'])
@@ -61,15 +61,15 @@
self.build_tree(['package-0.2/', 'package-0.2/README-NEW',
'package-0.2/CHANGELOG'])
write_to_file('package-0.2/CHANGELOG', 'version 2\n')
- tar = tarfile.open('package-0.2.tar.gz', 'w:gz')
+ tar = tarfile.open('../package-0.2.tar.gz', 'w:gz')
try:
tar.add('package-0.2')
finally:
tar.close()
shutil.rmtree('package-0.2')
- merge_upstream(wt, 'package-0.2.tar.gz',
+ merge_upstream(wt, '../package-0.2.tar.gz',
RevisionSpec.from_string("revid:" + old_upstream_revision))
- os.unlink('package-0.2.tar.gz')
+ os.unlink('../package-0.2.tar.gz')
return wt
def test_merge_upstream_gives_correct_tree(self):
@@ -105,6 +105,15 @@
parents = wt.get_parent_ids()
self.assertEqual(len(parents), 2)
self.assertEqual(parents[1], 'debian-1-1')
+ self.assertEqual(wt.conflicts(), [])
+
+ def test_merge_upstream_gives_correct_history(self):
+ wt = self.perform_upstream_merge()
+ rh = wt.branch.revision_history()
+ self.assertEqual(len(rh), 2)
+ self.assertEqual(rh[0], 'upstream-1')
+ self.assertEqual(wt.branch.repository.get_revision(rh[1]).message,
+ 'import upstream from package-0.2.tar.gz')
class TestConflictMergeUpstreamNormal(TestCaseWithTransport):
"""Test merge upstream with conflicts in the new version."""
@@ -119,7 +128,7 @@
# create the original upstream import
self.build_tree(['README', 'CHANGELOG'])
wt.add(['README', 'CHANGELOG'], ['README-id', 'CHANGELOG-id'])
- wt.commit('upstream version 1')
+ wt.commit('upstream version 1', rev_id='upstream-1')
old_upstream_revision = wt.branch.last_revision()
# create the debian branch on top
self.build_tree(['debian/', 'debian/changelog'])
@@ -186,9 +195,15 @@
[('CHANGELOG.BASE', None, 'file'),
('CHANGELOG.OTHER', None, 'file'),
('CHANGELOG.THIS', None, 'file')])
+
+ def test_merge_upstream_gives_correct_parents(self):
+ wt = self.perform_upstream_merge()
parents = wt.get_parent_ids()
self.assertEqual(len(parents), 2)
self.assertEqual(parents[1], 'debian-1-1')
+
+ def test_merge_upstream_gives_correct_conflicts(self):
+ wt = self.perform_upstream_merge()
conflicts = wt.conflicts()
self.assertEqual(len(conflicts), 2)
self.assertEqual(conflicts[0].path, 'CHANGELOG')
@@ -199,3 +214,11 @@
self.assertEqual(conflicts[1].conflict_file_id, 'debian-id')
self.assertEqual(conflicts[1].typestring, 'duplicate')
+ def test_merge_upstream_gives_correct_history(self):
+ wt = self.perform_upstream_merge()
+ rh = wt.branch.revision_history()
+ self.assertEqual(len(rh), 2)
+ self.assertEqual(rh[0], 'upstream-1')
+ self.assertEqual(wt.branch.repository.get_revision(rh[1]).message,
+ 'import upstream from package-0.2.tar.gz')
+
More information about the Pkg-bazaar-commits
mailing list