Merge lp:~bialix/bzr/hidden_attr_on_unicode into lp:~bzr/bzr/trunk-old

Proposed by Alexander Belchenko
Status: Merged
Merged at revision: not available
Proposed branch: lp:~bialix/bzr/hidden_attr_on_unicode
Merge into: lp:~bzr/bzr/trunk-old
Diff against target: 83 lines
To merge this branch: bzr merge lp:~bialix/bzr/hidden_attr_on_unicode
Reviewer Review Type Date Requested Status
John A Meinel Approve
bzr-core Pending
Review via email: mp+8181@code.launchpad.net
To post a comment you must log in.
Revision history for this message
Alexander Belchenko (bialix) wrote :

Bzr has one latent bug related to create new .bzr directory inside unicode directory. The problem occurs when unicode path cannot be encoded in current user encoding, as pointed by INADA Naoki, see
https://bugs.launchpad.net/tortoisebzr/+bug/335362/comments/41

This is rare condition, but bug itself is very serious.
Please, merge for 1.17.

(This is 3rd version of my patch, started from merge directive in ML, and now I send it to LP as jml and vila suggested).

Revision history for this message
John A Meinel (jameinel) wrote :

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Alexander Belchenko wrote:
> You have been requested to review the proposed merge of lp:~bialix/bzr/hidden_attr_on_unicode into lp:bzr.
>
> Bzr has one latent bug related to create new .bzr directory inside unicode directory. The problem occurs when unicode path cannot be encoded in current user encoding, as pointed by INADA Naoki, see
> https://bugs.launchpad.net/tortoisebzr/+bug/335362/comments/41
>
> This is rare condition, but bug itself is very serious.
> Please, merge for 1.17.
>
> (This is 3rd version of my patch, started from merge directive in ML, and now I send it to LP as jml and vila suggested).
>
> --
> https://code.launchpad.net/~bialix/bzr/hidden_attr_on_unicode/+merge/8181
> You are requested to review the proposed merge of lp:~bialix/bzr/hidden_attr_on_unicode into lp:bzr.
>

As mentioned on Bundle Buggy, you need to add
"requireFeature(Unicode...)" for the tests, otherwise:

 vote approve

John
=:->

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (Cygwin)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iEYEARECAAYFAkpODmcACgkQJdeBCYSNAAMPSQCaA8V9Jw0JCqAfbG1tKbL52tXT
xAcAoI+o5mhlJxLqlw8gKioaCXTEaBzL
=ZGcT
-----END PGP SIGNATURE-----

review: Approve
Revision history for this message
Alexander Belchenko (bialix) wrote :

John A Meinel пишет:
> As mentioned on Bundle Buggy, you need to add
> "requireFeature(Unicode...)" for the tests, otherwise:

As I said in ML it's all about windows behavior. Can I just skip tests
when running not on Windows? They have no sense for Linux.

Revision history for this message
Vincent Ladeuil (vila) wrote :

Review: approve

>>>>> "bialix" == Alexander Belchenko <email address hidden> writes:

    bialix> John A Meinel пишет:
    >> As mentioned on Bundle Buggy, you need to add
    >> "requireFeature(Unicode...)" for the tests, otherwise:

    bialix> As I said in ML it's all about windows behavior. Can
    bialix> I just skip tests when running not on Windows? They
    bialix> have no sense for Linux.

Sorted out on IRC, I'll merge.

       Vincent

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'NEWS'
2--- NEWS 2009-07-03 09:16:56 +0000
3+++ NEWS 2009-07-03 14:35:11 +0000
4@@ -92,6 +92,10 @@
5 content plus the size of the compressed text. Related to bug #109114.
6 (John Arbash Meinel)
7
8+* Set hidden attribute on .bzr directory below unicode path should never
9+ fail with error. The operation should succeed even if bzr unable to set
10+ the attribute. (Alexander Belchenko, related to bug #335362).
11+
12 * Stacking will no longer accept requests to stack on the same
13 branch/repository. Existing branches that incorrectly reference the same
14 repository in a stacking configuration will now raise
15
16=== modified file 'bzrlib/tests/test_win32utils.py'
17--- bzrlib/tests/test_win32utils.py 2009-06-25 10:05:17 +0000
18+++ bzrlib/tests/test_win32utils.py 2009-07-03 14:35:11 +0000
19@@ -18,7 +18,13 @@
20 import sys
21
22 from bzrlib import osutils
23-from bzrlib.tests import TestCase, TestCaseInTempDir, TestSkipped, Feature
24+from bzrlib.tests import (
25+ Feature,
26+ TestCase,
27+ TestCaseInTempDir,
28+ TestSkipped,
29+ UnicodeFilenameFeature,
30+ )
31 from bzrlib.win32utils import glob_expand, get_app_path
32 from bzrlib import win32utils
33
34@@ -238,3 +244,20 @@
35
36 def restoreCtypes(self):
37 win32utils.has_ctypes = self.old_ctypes
38+
39+
40+class TestSetHidden(TestCaseInTempDir):
41+
42+ def test_unicode_dir(self):
43+ # we should handle unicode paths without errors
44+ self.requireFeature(UnicodeFilenameFeature)
45+ os.mkdir(u'\u1234')
46+ win32utils.set_file_attr_hidden(u'\u1234')
47+
48+ def test_dot_bzr_in_unicode_dir(self):
49+ # we should not raise traceback if we try to set hidden attribute
50+ # on .bzr directory below unicode path
51+ self.requireFeature(UnicodeFilenameFeature)
52+ os.makedirs(u'\u1234\\.bzr')
53+ path = osutils.abspath(u'\u1234\\.bzr')
54+ win32utils.set_file_attr_hidden(path)
55
56=== modified file 'bzrlib/win32utils.py'
57--- bzrlib/win32utils.py 2009-06-26 07:15:24 +0000
58+++ bzrlib/win32utils.py 2009-07-03 14:35:11 +0000
59@@ -66,6 +66,7 @@
60 suffix = 'W'
61 try:
62 import win32file
63+ import pywintypes
64 has_win32file = True
65 except ImportError:
66 has_win32file = False
67@@ -499,7 +500,15 @@
68 def set_file_attr_hidden(path):
69 """Set file attributes to hidden if possible"""
70 if has_win32file:
71- win32file.SetFileAttributes(path, win32file.FILE_ATTRIBUTE_HIDDEN)
72+ if winver != 'Windows 98':
73+ SetFileAttributes = win32file.SetFileAttributesW
74+ else:
75+ SetFileAttributes = win32file.SetFileAttributes
76+ try:
77+ SetFileAttributes(path, win32file.FILE_ATTRIBUTE_HIDDEN)
78+ except pywintypes.error, e:
79+ from bzrlib import trace
80+ trace.mutter('Unable to set hidden attribute on %r: %s', path, e)
81
82
83 if has_ctypes and winver != 'Windows 98':