Merge lp:~jelmer/brz/support-backslash into lp:brz

Proposed by Jelmer Vernooij
Status: Merged
Merged at revision: 6845
Proposed branch: lp:~jelmer/brz/support-backslash
Merge into: lp:brz
Diff against target: 109 lines (+47/-1)
6 files modified
breezy/bzr/inventory.py (+1/-1)
breezy/tests/features.py (+23/-0)
breezy/tests/test_features.py (+9/-0)
breezy/tests/test_inv.py (+8/-0)
doc/en/release-notes/brz-3.0.txt (+3/-0)
doc/en/release-notes/bzr-2.6.txt (+3/-0)
To merge this branch: bzr merge lp:~jelmer/brz/support-backslash
Reviewer Review Type Date Requested Status
Martin Packman Approve
Review via email: mp+336071@code.launchpad.net

Description of the change

Support backslashes in filenames.

To post a comment you must log in.
Revision history for this message
Martin Packman (gz) wrote :

Am a little leery of landing this without a better mechanism for dealing with uncheckaboutable files on Windows, but really this doesn't make things much worse than already exists with special filenames. See one inline comment to change.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'breezy/bzr/inventory.py'
2--- breezy/bzr/inventory.py 2017-11-13 22:52:33 +0000
3+++ breezy/bzr/inventory.py 2018-01-14 05:56:18 +0000
4@@ -222,7 +222,7 @@
5 Traceback (most recent call last):
6 InvalidEntryName: Invalid entry name: src/hello.c
7 """
8- if u'/' in name or u'\\' in name:
9+ if u'/' in name:
10 raise errors.InvalidEntryName(name=name)
11 self.file_id = file_id
12 self.revision = None
13
14=== modified file 'breezy/tests/features.py'
15--- breezy/tests/features.py 2017-11-11 18:13:55 +0000
16+++ breezy/tests/features.py 2018-01-14 05:56:18 +0000
17@@ -533,6 +533,29 @@
18 win32_feature = Win32Feature()
19
20
21+class _BackslashFilenameFeature(Feature):
22+ """Does the filesystem support backslashes in filenames?"""
23+
24+ def _probe(self):
25+
26+ try:
27+ fileno, name = tempfile.mkstemp(prefix='bzr\\prefix')
28+ except (IOError, OSError):
29+ return False
30+ else:
31+ try:
32+ os.stat(name)
33+ except (IOError, OSError):
34+ # mkstemp succeeded but the file wasn't actually created
35+ return False
36+ os.close(fileno)
37+ os.remove(name)
38+ return True
39+
40+
41+BackslashFilenameFeature = _BackslashFilenameFeature()
42+
43+
44 class _ColorFeature(Feature):
45
46 def _probe(self):
47
48=== modified file 'breezy/tests/test_features.py'
49--- breezy/tests/test_features.py 2017-08-26 19:31:51 +0000
50+++ breezy/tests/test_features.py 2018-01-14 05:56:18 +0000
51@@ -155,3 +155,12 @@
52 # We can't test much more than that because the behaviour depends
53 # on the platform.
54 features.UnicodeFilenameFeature._probe()
55+
56+
57+class TestBackslashFilenameFeature(tests.TestCase):
58+
59+ def test_probe_passes(self):
60+ """BackslashFilenameFeature._probe passes."""
61+ # We can't test much more than that because the behaviour depends
62+ # on the platform.
63+ features.BackslashFilenameFeature._probe()
64
65=== modified file 'breezy/tests/test_inv.py'
66--- breezy/tests/test_inv.py 2017-08-05 01:03:53 +0000
67+++ breezy/tests/test_inv.py 2018-01-14 05:56:18 +0000
68@@ -700,6 +700,14 @@
69
70 class TestInventoryEntry(TestCase):
71
72+ def test_file_invalid_entry_name(self):
73+ self.assertRaises(errors.InvalidEntryName, inventory.InventoryFile,
74+ '123', 'a/hello.c', ROOT_ID)
75+
76+ def test_file_backslash(self):
77+ file = inventory.InventoryFile('123', 'h\\ello.c', ROOT_ID)
78+ self.assertEquals(file.name, 'h\\ello.c')
79+
80 def test_file_kind_character(self):
81 file = inventory.InventoryFile('123', 'hello.c', ROOT_ID)
82 self.assertEqual(file.kind_character(), '')
83
84=== modified file 'doc/en/release-notes/brz-3.0.txt'
85--- doc/en/release-notes/brz-3.0.txt 2017-12-19 22:38:08 +0000
86+++ doc/en/release-notes/brz-3.0.txt 2018-01-14 05:56:18 +0000
87@@ -152,6 +152,9 @@
88 * Avoid writing directly to sys.stdout, but use self.outf in
89 Command implementations instead. (#268573, B. Clausius)
90
91+* It is now possible to version files with backslashes in their name
92+ on platforms that support it. (Jelmer Vernooij, #81844)
93+
94 Documentation
95 *************
96
97
98=== modified file 'doc/en/release-notes/bzr-2.6.txt'
99--- doc/en/release-notes/bzr-2.6.txt 2013-08-04 11:45:53 +0000
100+++ doc/en/release-notes/bzr-2.6.txt 2018-01-14 05:56:18 +0000
101@@ -279,6 +279,9 @@
102 Bug Fixes
103 *********
104
105+.. Fixes for situations where bzr would previously crash or give incorrect
106+ or undesirable results.
107+
108 * Fix ``bzr config`` display for ``RegistryOption`` values.
109 (Vincent Ladeuil, #930182)
110

Subscribers

People subscribed via source and target branches