Rev 614: Fix bug #286834 bu handling 'missing' files corner case. in file:///v/home/vila/.bazaar/plugins/gtk/
Vincent Ladeuil
v.ladeuil+lp at free.fr
Wed Oct 22 08:56:58 BST 2008
At file:///v/home/vila/.bazaar/plugins/gtk/
------------------------------------------------------------
revno: 614
revision-id: v.ladeuil+lp at free.fr-20081022075653-10v8wlpmisbotnjg
parent: v.ladeuil+lp at free.fr-20081021121728-p5sd5w25v43u7dpk
committer: Vincent Ladeuil <v.ladeuil+lp at free.fr>
branch nick: gtk
timestamp: Wed 2008-10-22 09:56:53 +0200
message:
Fix bug #286834 bu handling 'missing' files corner case.
* tests/test_diff.py:
(Test_IterChangesToStatus.test_status_missing_file, )
(Test_IterChangesToStatus.test_status_removed): Add tests.
* diff.py:
(iter_changes_to_status): Handle 'missing' files corner case.
-------------- next part --------------
=== modified file 'diff.py'
--- a/diff.py 2008-10-07 20:59:01 +0000
+++ b/diff.py 2008-10-22 07:56:53 +0000
@@ -1,11 +1,10 @@
-# -*- coding: UTF-8 -*-
"""Difference window.
This module contains the code to manage the diff window which shows
the changes made between two revisions on a branch.
"""
-__copyright__ = "Copyright ?? 2005 Canonical Ltd."
+__copyright__ = "Copyright 2005 Canonical Ltd."
__author__ = "Scott James Remnant <scott at ubuntu.com>"
@@ -635,6 +634,7 @@
renamed_and_modified = 'renamed and modified'
modified = 'modified'
kind_changed = 'kind changed'
+ missing = 'missing'
# TODO: Handle metadata changes
@@ -655,9 +655,15 @@
source_marker = ''
else:
source_marker = osutils.kind_marker(kinds[0])
+
if kinds[1] is None:
- assert kinds[0] is not None
- marker = osutils.kind_marker(kinds[0])
+ if kinds[0] is None:
+ # We assume bzr will flag only files in that case,
+ # there may be a bzr bug there as only files seems to
+ # not receive any kind.
+ marker = osutils.kind_marker('file')
+ else:
+ marker = osutils.kind_marker(kinds[0])
else:
marker = osutils.kind_marker(kinds[1])
@@ -665,17 +671,20 @@
if real_path is None:
real_path = paths[0]
assert real_path is not None
- display_path = real_path + marker
present_source = versioned[0] and kinds[0] is not None
present_target = versioned[1] and kinds[1] is not None
- if present_source != present_target:
+ if kinds[0] is None and kinds[1] is None:
+ change_type = missing
+ display_path = real_path + marker
+ elif present_source != present_target:
if present_target:
change_type = added
else:
assert present_source
change_type = removed
+ display_path = real_path + marker
elif names[0] != names[1] or parent_ids[0] != parent_ids[1]:
# Renamed
if changed_content or executables[0] != executables[1]:
@@ -691,6 +700,7 @@
+ ' => ' + paths[1] + marker)
elif changed_content or executables[0] != executables[1]:
change_type = modified
+ display_path = real_path + marker
else:
assert False, "How did we get here?"
=== modified file 'tests/test_diff.py'
--- a/tests/test_diff.py 2008-06-09 15:59:13 +0000
+++ b/tests/test_diff.py 2008-10-22 07:56:53 +0000
@@ -18,7 +18,11 @@
from cStringIO import StringIO
import os
-from bzrlib import errors, tests
+from bzrlib import (
+ conflicts,
+ errors,
+ tests,
+ )
from bzrlib.merge_directive import MergeDirective2
from bzrlib.plugins.gtk.diff import (
@@ -303,3 +307,57 @@
[('a-id', 'a', 'removed', 'a'),
('b-id', 'b', 'removed', 'b/'),
], tree)
+
+ def test_status_missing_file(self):
+ this = self.make_branch_and_tree('this')
+ self.build_tree(['this/foo'])
+ this.add(['foo'], ['foo-id'])
+ this.commit('add')
+
+ other = this.bzrdir.sprout('other').open_workingtree()
+
+ os.remove('this/foo')
+ this.remove('foo', force=True)
+ this.commit('remove')
+
+ f = open('other/foo', 'wt')
+ try:
+ f.write('Modified\n')
+ finally:
+ f.close()
+ other.commit('modified')
+
+ this.merge_from_branch(other.branch)
+ conflicts.resolve(this)
+
+ self.assertStatusEqual(
+ [('foo-id', 'foo.OTHER', 'missing', 'foo.OTHER'),],
+ this)
+
+ def test_status_missing_directory(self):
+ this = self.make_branch_and_tree('this')
+ self.build_tree(['this/foo/', 'this/foo/bar'])
+ this.add(['foo', 'foo/bar'], ['foo-id', 'bar-id'])
+ this.commit('add')
+
+ other = this.bzrdir.sprout('other').open_workingtree()
+
+ os.remove('this/foo/bar')
+ os.rmdir('this/foo')
+ this.remove('foo', force=True)
+ this.commit('remove')
+
+ f = open('other/foo/bar', 'wt')
+ try:
+ f.write('Modified\n')
+ finally:
+ f.close()
+ other.commit('modified')
+
+ this.merge_from_branch(other.branch)
+ conflicts.resolve(this)
+
+ self.assertStatusEqual(
+ [('foo-id', u'foo', 'added', u'foo/'),
+ ('bar-id', u'foo/bar.OTHER', 'missing', u'foo/bar.OTHER'),],
+ this)
More information about the bazaar-commits
mailing list