Rev 4507: Setting hidden attribute on win32 should never fail. in http://bazaar.launchpad.net/%7Evila/bzr/integration
Vincent Ladeuil
v.ladeuil+lp at free.fr
Fri Jul 3 15:41:44 BST 2009
At http://bazaar.launchpad.net/%7Evila/bzr/integration
------------------------------------------------------------
revno: 4507 [merge]
revision-id: v.ladeuil+lp at free.fr-20090703144131-gtrc803t0qs6olv0
parent: pqm at pqm.ubuntu.com-20090703102135-edbqugohr9mu020k
parent: bialix at ukr.net-20090703142634-nnnan3bfbx33a2ly
committer: Vincent Ladeuil <v.ladeuil+lp at free.fr>
branch nick: integration
timestamp: Fri 2009-07-03 16:41:31 +0200
message:
Setting hidden attribute on win32 should never fail.
modified:
NEWS NEWS-20050323055033-4e00b5db738777ff
bzrlib/tests/test_win32utils.py test_win32utils.py-20070713181630-8xsrjymd3e8mgw23-108
bzrlib/win32utils.py win32console.py-20051021033308-123c6c929d04973d
-------------- next part --------------
=== modified file 'NEWS'
--- a/NEWS 2009-07-03 09:16:56 +0000
+++ b/NEWS 2009-07-03 14:41:31 +0000
@@ -92,6 +92,10 @@
content plus the size of the compressed text. Related to bug #109114.
(John Arbash Meinel)
+* Set hidden attribute on .bzr directory below unicode path should never
+ fail with error. The operation should succeed even if bzr unable to set
+ the attribute. (Alexander Belchenko, related to bug #335362).
+
* Stacking will no longer accept requests to stack on the same
branch/repository. Existing branches that incorrectly reference the same
repository in a stacking configuration will now raise
=== modified file 'bzrlib/tests/test_win32utils.py'
--- a/bzrlib/tests/test_win32utils.py 2009-06-25 10:05:17 +0000
+++ b/bzrlib/tests/test_win32utils.py 2009-07-03 14:26:34 +0000
@@ -18,7 +18,13 @@
import sys
from bzrlib import osutils
-from bzrlib.tests import TestCase, TestCaseInTempDir, TestSkipped, Feature
+from bzrlib.tests import (
+ Feature,
+ TestCase,
+ TestCaseInTempDir,
+ TestSkipped,
+ UnicodeFilenameFeature,
+ )
from bzrlib.win32utils import glob_expand, get_app_path
from bzrlib import win32utils
@@ -238,3 +244,20 @@
def restoreCtypes(self):
win32utils.has_ctypes = self.old_ctypes
+
+
+class TestSetHidden(TestCaseInTempDir):
+
+ def test_unicode_dir(self):
+ # we should handle unicode paths without errors
+ self.requireFeature(UnicodeFilenameFeature)
+ os.mkdir(u'\u1234')
+ win32utils.set_file_attr_hidden(u'\u1234')
+
+ def test_dot_bzr_in_unicode_dir(self):
+ # we should not raise traceback if we try to set hidden attribute
+ # on .bzr directory below unicode path
+ self.requireFeature(UnicodeFilenameFeature)
+ os.makedirs(u'\u1234\\.bzr')
+ path = osutils.abspath(u'\u1234\\.bzr')
+ win32utils.set_file_attr_hidden(path)
=== modified file 'bzrlib/win32utils.py'
--- a/bzrlib/win32utils.py 2009-06-26 07:15:24 +0000
+++ b/bzrlib/win32utils.py 2009-07-03 10:40:59 +0000
@@ -66,6 +66,7 @@
suffix = 'W'
try:
import win32file
+ import pywintypes
has_win32file = True
except ImportError:
has_win32file = False
@@ -499,7 +500,15 @@
def set_file_attr_hidden(path):
"""Set file attributes to hidden if possible"""
if has_win32file:
- win32file.SetFileAttributes(path, win32file.FILE_ATTRIBUTE_HIDDEN)
+ if winver != 'Windows 98':
+ SetFileAttributes = win32file.SetFileAttributesW
+ else:
+ SetFileAttributes = win32file.SetFileAttributes
+ try:
+ SetFileAttributes(path, win32file.FILE_ATTRIBUTE_HIDDEN)
+ except pywintypes.error, e:
+ from bzrlib import trace
+ trace.mutter('Unable to set hidden attribute on %r: %s', path, e)
if has_ctypes and winver != 'Windows 98':
More information about the bazaar-commits
mailing list