Fix with tests attached,

    Vincent

# Bazaar merge directive format 2 (Bazaar 0.90)
# revision_id: [EMAIL PROTECTED]
# target_branch: http://bazaar.launchpad.net/%7Ebzr-gtk/bzr-gtk/trunk
# testament_sha1: 013d23a5b398bbf85ffd21919b29a468bb003907
# timestamp: 2008-10-22 09:58:21 +0200
# base_revision_id: [EMAIL PROTECTED]
#   p5sd5w25v43u7dpk
# 
# Begin patch
=== modified file 'diff.py'
--- diff.py	2008-10-07 20:59:01 +0000
+++ 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 <[EMAIL PROTECTED]>"
 
 
@@ -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'
--- tests/test_diff.py	2008-06-09 15:59:13 +0000
+++ 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)

# Begin bundle
IyBCYXphYXIgcmV2aXNpb24gYnVuZGxlIHY0CiMKQlpoOTFBWSZTWTikXBMAA91/gER0RAB5////
e2edjr////BgCB8XrWxIAFmDIAFApKYSiTFJ6eqeU9RtRtTJoB6mgNDRoBoaBoNqAHDTTBDIaaZG
TCAaaAMJo0yYAEDQ4aaYIZDTTIyYQDTQBhNGmTAAgaCU0RTKeSE9piT1BoymENNDQAZGjEAGmg4a
aYIZDTTIyYQDTQBhNGmTAAgaCSTQQAmQQDI0U9E9NGk2iYkZMhozUDEqSSN2XMwjaPB+TtHbS5+v
6Gn6WfkcOPTz2kJtaOMMMwwwxaMKAwSHCKtxehZTjG6rU5JrR8lWmTtqhPtjKKCxkHZTU1IHa8oY
u1Un7dqABUBJMW3Yx2EIomxIVQZ5paTxkVFUcoHvjAuRvHzMn0BjlPKnoppUlKgQk00Td5XRKWpH
TkyfQzljfocz9xZMzk3bJXQ/dL9h6uqg0tQOJ5dIEshVqN+8lUHVI+gdzJJS6hu57JBpKxw1uOxK
I5bpINddlCJVmFvf4d3Db8t5dnVaIpjZpZrZyAxteVoJgRkyvS0UBZHZ5eLY/pxjydOonkTeaJE1
ykpQO8FaS0flxCFBCQmIBONAOJaXHwrcoRDEYdRZHkXECt4+BHmYz7zAYgMN5+ihFSGHCZBFnCCO
8vsvJrNCdVnnZWIZyAnNp/3eBqKmM/BkjgcedOzQ2HkbFZZlalplVUliLxxDiLXIEUsMj+sNMcyj
m0IIZsQhykzMhrpE0yXvYh6Lqy21em1PjBvOmFpCOsYVGQqNNOfWyEy1FR6BlPduB5jDDRAZCcqu
VfWnKy098hGFn3wSINe490Y1DJFZj4FQFSq9liawsjTHPCv8TzTUNZZrL6oE5lS8p85Ytm+9bjE6
Tc+Ri2wQYviA0d0VHFQAeFB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slwofXvyNoFfu8EXLqSxS84mxLDqVrtNv3IHIpTaUEiRjZUgI
BAgl8Ez2js4NIEQ06wIEaVJTYTJ985pIofAe4/8W+ziQ7GGSuQfstjrhqMUkUuc6Bw9dJImcRk5L
oJB9i4lha50HeQIG75gaWm1KPIoWoVp2dnAOsU1vrA9CuVgEtO24uuGocoFh+Z8Til0scYdEHGTc
GcE4QBxgKI3JRwcoSMAp0CrQtnKYBC1LMcz8bDRk/3XlTV8hwIpajUyuYyyVWIdDFsxgZjuNjqkV
rE2xrCBr8RUiANkQUkCmQNFCFAjaCAO/OSA+aoWqvdwOAQKzfYUgtE4i1BAuCZB1sHKDiGgkRRRE
ApC4yn39kI8pYGYxZ52UFRjK0FfYCcEtZdoIOvGYrO0jp7qV5eeOUDZMgz3jCNg4To2hQSEBIad5
gTNiQD3xcxm42IkRiFhKTDDOVsGmCBynCwPxX8HXM8Zm8SRvcXFrmXOwIc7d/bRujgjrOFukDNqD
bwsGyMFx0UtdbZsI6gNk3zQYcuezXYew1cmzyEIFIQ5E2hpG1w7CRoseahsf4u5IpwoSBxSLgmA=
-- 
bzr-gtk mailing list
[email protected]
Modify settings or unsubscribe at: 
https://lists.canonical.com/mailman/listinfo/bzr-gtk

Reply via email to