# Bazaar merge directive format 2 (Bazaar 0.90)
# revision_id: bialix@ukr.net-20071119225430-x0ewosrsagis0yno
# target_branch: file:///C:/work/Bazaar/mydev/bzr.dev/
# testament_sha1: af75d0c4da99d8edc8f890d5724e3c8fb9e3140c
# timestamp: 2007-11-20 00:54:40 +0200
# base_revision_id: pqm@pqm.ubuntu.com-20071117180742-59zhz30s7839y41j
# 
# Begin patch
=== modified file 'NEWS'
--- NEWS	2007-11-17 18:07:42 +0000
+++ NEWS	2007-11-19 22:54:30 +0000
@@ -82,6 +82,9 @@
    * Removing an already-removed file reports the file does not exist. (Daniel
      Watkins, #152811)
 
+   * Rename on Windows is able to change filename case.
+     (Alexander Belchenko, #77740)
+
    * Stderr output via logging mechanism now goes through encoded wrapper
      and no more uses utf-8, but terminal encoding instead. So all unicode
      strings now should be readable in non-utf-8 terminal.

=== modified file 'bzrlib/osutils.py'
--- bzrlib/osutils.py	2007-11-04 11:45:30 +0000
+++ bzrlib/osutils.py	2007-11-19 22:51:14 +0000
@@ -234,10 +234,17 @@
 
     success = False
     try:
-        # This may throw an exception, in which case success will
-        # not be set.
-        rename_func(old, new)
-        success = True
+        try:
+            # This may throw an exception, in which case success will
+            # not be set.
+            rename_func(old, new)
+            success = True
+        except (IOError, OSError), e:
+            # source and target may be aliases of each other (e.g. on a
+            # case-insensitive filesystem), so we may have accidentally renamed
+            # source by when we tried to rename target
+            if not (file_existed and e.errno in (None, errno.ENOENT)):
+                raise
     finally:
         if file_existed:
             # If the file used to exist, rename it back into place

=== modified file 'bzrlib/tests/blackbox/test_mv.py'
--- bzrlib/tests/blackbox/test_mv.py	2007-11-06 04:33:38 +0000
+++ bzrlib/tests/blackbox/test_mv.py	2007-11-19 22:54:30 +0000
@@ -124,6 +124,19 @@
         os.chdir('..')
         self.assertMoved('sub1/sub2/hello.txt','sub1/hello.txt')
 
+    def test_mv_change_case(self):
+        # test for bug #77740 (mv unable change filename case on Windows)
+        tree = self.make_branch_and_tree('.')
+        self.build_tree(['test.txt'])
+        tree.add(['test.txt'])
+        self.run_bzr('mv test.txt Test.txt')
+        # we can't use failUnlessExists on case-insensitive filesystem
+        # so try to check shape of the tree
+        shape = sorted(os.listdir(u'.'))
+        self.assertEqual(['.bzr', 'Test.txt'], shape)
+        self.assertInWorkingTree('Test.txt')
+        self.assertNotInWorkingTree('test.txt')
+
     def test_mv_smoke_aliases(self):
         # just test that aliases for mv exist, if their behaviour is changed in
         # the future, then extend the tests.

=== modified file 'bzrlib/tests/test_osutils.py'
--- bzrlib/tests/test_osutils.py	2007-11-03 09:39:11 +0000
+++ bzrlib/tests/test_osutils.py	2007-11-12 21:35:15 +0000
@@ -93,6 +93,16 @@
 
     # TODO: test fancy_rename using a MemoryTransport
 
+    def test_rename_change_case(self):
+        # on Windows we should be able to change filename case by rename
+        self.build_tree(['a', 'b/'])
+        osutils.rename('a', 'A')
+        osutils.rename('b', 'B')
+        # we can't use failUnlessExists on case-insensitive filesystem
+        # so try to check shape of the tree
+        shape = sorted(os.listdir('.'))
+        self.assertEquals(['A', 'B'], shape)
+
     def test_01_rand_chars_empty(self):
         result = osutils.rand_chars(0)
         self.assertEqual(result, '')

=== modified file 'bzrlib/workingtree.py'
--- bzrlib/workingtree.py	2007-11-14 10:53:53 +0000
+++ bzrlib/workingtree.py	2007-11-19 22:54:30 +0000
@@ -1318,6 +1318,10 @@
                 only_change_inv = True
             elif self.has_filename(from_rel) and not self.has_filename(to_rel):
                 only_change_inv = False
+            elif (sys.platform == 'win32'
+                and from_rel.lower() == to_rel.lower()
+                and self.has_filename(from_rel)):
+                only_change_inv = False
             else:
                 # something is wrong, so lets determine what exactly
                 if not self.has_filename(from_rel) and \

# Begin bundle
IyBCYXphYXIgcmV2aXNpb24gYnVuZGxlIHY0CiMKQlpoOTFBWSZTWaVzLEoADeNfgGRUeff///ch
noq////wYBLuHoaBXrvtpg0NAKpKqFFAozVTGbSNslbRUkKo0wo21jNFDJEmBT0INqe0U9JvUgeo
0Mahgg0ZGRhDmmRkMmC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