[Pkg-bazaar-commits] r213 ./bzr-builddeb/people/jdw/dev: * Filter out any changes to .bzr in packages that are being imported as they
James Westby
jw+debian at jameswestby.net
Tue Oct 30 21:01:14 UTC 2007
------------------------------------------------------------
revno: 213
committer: James Westby <jw+debian at jameswestby.net>
branch nick: dev
timestamp: Tue 2007-10-30 21:01:14 +0000
message:
* Filter out any changes to .bzr in packages that are being imported as they
will totally mess things up. If the branch is in the source package then
just use apt-get source. (LP: #156003)
modified:
debian/changelog
import_dsc.py
tests/test_import_dsc.py
-------------- next part --------------
=== modified file 'debian/changelog'
--- a/debian/changelog 2007-10-30 14:34:51 +0000
+++ b/debian/changelog 2007-10-30 21:01:14 +0000
@@ -4,8 +4,11 @@
for uploads done outside the VCS.
* Also look for upstream tarballs in the archives. Do this in preference
to the watch file, for the case where the upstream was repacked.
+ * Filter out any changes to .bzr in packages that are being imported as they
+ will totally mess things up. If the branch is in the source package then
+ just use apt-get source. (LP: #156003)
- -- James Westby <jw+debian at jameswestby.net> Tue, 30 Oct 2007 14:33:50 +0000
+ -- James Westby <jw+debian at jameswestby.net> Tue, 30 Oct 2007 20:58:46 +0000
bzr-builddeb (0.91) unstable; urgency=low
=== modified file 'import_dsc.py'
--- a/import_dsc.py 2007-10-29 21:17:57 +0000
+++ b/import_dsc.py 2007-10-30 21:01:14 +0000
@@ -39,7 +39,7 @@
)
from bzrlib.config import ConfigObj
from bzrlib.errors import FileExists, BzrError, UncommittedChanges
-from bzrlib.osutils import file_iterator, isdir, basename
+from bzrlib.osutils import file_iterator, isdir, basename, splitpath
from bzrlib.revision import NULL_REVISION
from bzrlib.trace import warning, info
from bzrlib.transform import TreeTransform, cook_conflicts, resolve_conflicts
@@ -97,6 +97,14 @@
relative_path = relative_path.rstrip('/')
if relative_path == '':
continue
+ parts = splitpath(relative_path)
+ if parts:
+ check_part = parts[0]
+ if prefix is not None and len(parts) > 1:
+ if parts[0] == prefix:
+ check_part = parts[1]
+ if check_part == '.bzr':
+ continue
add_implied_parents(implied_parents, relative_path)
trans_id = tt.trans_id_tree_path(relative_path)
added.add(relative_path.rstrip('/'))
@@ -327,20 +335,34 @@
finally:
f.close()
+ def _filter_patch(self, patch):
+ filter_cmd = ['filterdiff', '-x', '*/.bzr/*']
+ filter_proc = Popen(filter_cmd, stdin=PIPE, stdout=PIPE)
+ for line in patch:
+ filter_proc.stdin.write(line)
+ filter_proc.stdin.close()
+ r = filter_proc.wait()
+ if r != 0:
+ raise BzrError('filtering patch failed')
+ filtered_patch = filter_proc.stdout.readlines()
+ return filtered_patch
+
+
def _patch_tree(self, patch, basedir):
- cmd = ['patch', '--strip', '1', '--quiet', '--directory', basedir]
- child_proc = Popen(cmd, stdin=PIPE)
- for line in patch:
- child_proc.stdin.write(line)
- child_proc.stdin.close()
- r = child_proc.wait()
+ patch_cmd = ['patch', '--strip', '1', '--quiet', '-f', '--directory',
+ basedir]
+ patch_proc = Popen(patch_cmd, stdin=PIPE)
+ for line in self._filter_patch(patch):
+ patch_proc.stdin.write(line)
+ patch_proc.stdin.close()
+ r = patch_proc.wait()
if r != 0:
raise BzrError('patch failed')
def _get_touched_paths(self, patch):
cmd = ['lsdiff', '--strip', '1']
child_proc = Popen(cmd, stdin=PIPE, stdout=PIPE)
- for line in patch:
+ for line in self._filter_patch(patch):
child_proc.stdin.write(line)
child_proc.stdin.close()
r = child_proc.wait()
=== modified file 'tests/test_import_dsc.py'
--- a/tests/test_import_dsc.py 2007-10-29 21:17:57 +0000
+++ b/tests/test_import_dsc.py 2007-10-30 21:01:14 +0000
@@ -97,6 +97,10 @@
def make_orig_2(self):
self.extend_base_package()
+ if not os.path.exists(os.path.join(self.basedir, '.bzr')):
+ os.mkdir(os.path.join(self.basedir, '.bzr'))
+ write_to_file(os.path.join(self.basedir, '.bzr', 'branch-format'),
+ 'broken format')
tar = tarfile.open(self.orig_2, 'w:gz')
try:
tar.add(self.basedir)
@@ -105,6 +109,7 @@
def make_orig_3(self):
self.extend_base_package2()
+ shutil.rmtree(os.path.join(self.basedir, '.bzr'))
tar = tarfile.open(self.orig_3, 'w:gz')
try:
tar.add(self.basedir)
@@ -155,6 +160,9 @@
def make_diff_3(self):
diffdir = 'package-0.3'
shutil.copytree(self.basedir, diffdir)
+ os.mkdir(os.path.join(diffdir, '.bzr'))
+ write_to_file(os.path.join(diffdir, '.bzr', 'branch-format'),
+ 'broken format')
os.mkdir(os.path.join(diffdir, 'debian'))
write_to_file(os.path.join(diffdir, 'debian', 'changelog'),
'version 1-1\nversion 1-2\nversion 1-3\nversion 2-1\nversion 3-1\n')
@@ -539,18 +547,28 @@
self.failUnlessExists(os.path.join(self.target, path))
self.assertRulesExecutable(tree)
+ def _add_debian_to_native(self):
+ os.mkdir(os.path.join(self.basedir, 'debian'))
+ write_to_file(os.path.join(self.basedir, 'debian', 'changelog'),
+ 'version 1\n')
+ write_to_file(os.path.join(self.basedir, 'debian', 'rules'), '\n')
+
+ def _make_native(self, tarball_name, dsc_name):
+ tar = tarfile.open(tarball_name, 'w:gz')
+ try:
+ tar.add(self.basedir)
+ finally:
+ tar.close()
+ self.make_dsc(dsc_name, '0.1', tarball_name)
+
+
def make_native_dsc_1(self):
self.make_base_package()
- os.mkdir(os.path.join(self.basedir, 'debian'))
- write_to_file(os.path.join(self.basedir, 'debian', 'changelog'),
- 'version 1\n')
- write_to_file(os.path.join(self.basedir, 'debian', 'rules'), '\n')
- tar = tarfile.open(self.native_1, 'w:gz')
- try:
- tar.add(self.basedir)
- finally:
- tar.close()
- self.make_dsc(self.native_dsc_1, '0.1', self.native_1)
+ self._add_debian_to_native()
+ os.mkdir(os.path.join(self.basedir, '.bzr'))
+ write_to_file(os.path.join(self.basedir, '.bzr', 'branch-format'),
+ 'broken format')
+ self._make_native(self.native_1, self.native_dsc_1)
def make_native_dsc_2(self):
self.extend_base_package()
More information about the Pkg-bazaar-commits
mailing list