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

Proposed by Jelmer Vernooij on 2018-09-17
Status: Merged
Approved by: Jelmer Vernooij on 2018-11-17
Approved revision: 7123
Merge reported by: The Breezy Bot
Merged at revision: not available
Proposed branch: lp:~jelmer/brz/backslash-support
Merge into: lp:brz
Diff against target: 111 lines (+50/-6)
5 files modified
breezy/osutils.py (+11/-5)
breezy/tests/blackbox/test_add.py (+13/-0)
breezy/tests/blackbox/test_remove.py (+13/-0)
breezy/tests/test_osutils.py (+4/-1)
doc/en/release-notes/brz-3.0.txt (+9/-0)
To merge this branch: bzr merge lp:~jelmer/brz/backslash-support
Reviewer Review Type Date Requested Status
Martin Packman 2018-09-17 Approve on 2018-11-17
Review via email: mp+355135@code.launchpad.net

Commit message

Support adding files with filenames that are just a backslash on
platforms where it is not the path separator.

Description of the change

Support adding files with filenames that are just a backslash on
platforms where it is not the path separator.

To post a comment you must log in.
Martin Packman (gz) wrote :

Okay, this still terrifies me, but I guess all we're really doing is giving *nix users one more in a long list of footguns.

Jelmer Vernooij (jelmer) wrote :

I think the main consequence of this is that it's possible to create branches that can not be checked out on Windows. However, this is already possible - there is a separate bug open about warning in cases like this: bug 1743186

Martin Packman (gz) wrote :

Okay, lets do it.

review: Approve
lp:~jelmer/brz/backslash-support updated on 2018-11-17
7123. By Jelmer Vernooij on 2018-11-17

Merge trunk.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'breezy/osutils.py'
2--- breezy/osutils.py 2018-11-12 01:41:38 +0000
3+++ breezy/osutils.py 2018-11-17 18:51:40 +0000
4@@ -1035,12 +1035,18 @@
5
6 def splitpath(p):
7 """Turn string into list of parts."""
8- # split on either delimiter because people might use either on
9- # Windows
10- if isinstance(p, bytes):
11- ps = re.split(b'[\\\\/]', p)
12+ if os.path.sep == '\\':
13+ # split on either delimiter because people might use either on
14+ # Windows
15+ if isinstance(p, bytes):
16+ ps = re.split(b'[\\\\/]', p)
17+ else:
18+ ps = re.split(r'[\\/]', p)
19 else:
20- ps = re.split(r'[\\/]', p)
21+ if isinstance(p, bytes):
22+ ps = p.split(b'/')
23+ else:
24+ ps = p.split('/')
25
26 rps = []
27 for f in ps:
28
29=== modified file 'breezy/tests/blackbox/test_add.py'
30--- breezy/tests/blackbox/test_add.py 2018-11-11 04:08:32 +0000
31+++ breezy/tests/blackbox/test_add.py 2018-11-17 18:51:40 +0000
32@@ -265,3 +265,16 @@
33 out = self.run_bzr('add')[0]
34 results = sorted(out.rstrip('\n').split('\n'))
35 self.assertEqual(['adding big.txt'], results)
36+
37+ def test_add_backslash(self):
38+ # pad.lv/165151
39+ if os.path.sep == '\\':
40+ # TODO(jelmer): Test that backslashes are appropriately
41+ # ignored?
42+ raise tests.TestNotApplicable(
43+ 'unable to add filenames with backslashes where '
44+ ' it is the path separator')
45+ tree = self.make_branch_and_tree('.')
46+ self.build_tree(['\\'])
47+ self.assertEqual('adding \\\n', self.run_bzr('add \\\\')[0])
48+ self.assertEqual('\\\n', self.run_bzr('ls --versioned')[0])
49
50=== modified file 'breezy/tests/blackbox/test_remove.py'
51--- breezy/tests/blackbox/test_remove.py 2018-11-11 04:08:32 +0000
52+++ breezy/tests/blackbox/test_remove.py 2018-11-17 18:51:40 +0000
53@@ -274,3 +274,16 @@
54 error_regexes=["removed a", "removed b", "removed b/c"])
55 tree = WorkingTree.open('.')
56 self.assertFilesUnversioned(files)
57+
58+ def test_remove_backslash(self):
59+ # pad.lv/176263
60+ if os.path.sep == '\\':
61+ raise tests.TestNotApplicable(
62+ 'unable to add filenames with backslashes where '
63+ ' it is the path separator')
64+ tree = self.make_branch_and_tree('.')
65+ self.build_tree(['\\'])
66+ self.assertEqual('adding \\\n', self.run_bzr('add \\\\')[0])
67+ self.assertEqual('\\\n', self.run_bzr('ls --versioned')[0])
68+ self.assertEqual('', self.run_bzr('rm \\\\')[0])
69+ self.assertEqual('', self.run_bzr('ls --versioned')[0])
70
71=== modified file 'breezy/tests/test_osutils.py'
72--- breezy/tests/test_osutils.py 2018-11-12 01:41:38 +0000
73+++ breezy/tests/test_osutils.py 2018-11-17 18:51:40 +0000
74@@ -1058,7 +1058,10 @@
75 check(['a', 'b'], 'a/b')
76 check(['a', 'b'], 'a/./b')
77 check(['a', '.b'], 'a/.b')
78- check(['a', '.b'], 'a\\.b')
79+ if os.path.sep == '\\':
80+ check(['a', '.b'], 'a\\.b')
81+ else:
82+ check(['a\\.b'], 'a\\.b')
83
84 self.assertRaises(errors.BzrError, osutils.splitpath, 'a/../b')
85
86
87=== modified file 'doc/en/release-notes/brz-3.0.txt'
88--- doc/en/release-notes/brz-3.0.txt 2018-11-16 07:18:33 +0000
89+++ doc/en/release-notes/brz-3.0.txt 2018-11-17 18:51:40 +0000
90@@ -67,6 +67,11 @@
91 has been renamed to ``transform.orphan_policy``.
92 (Jelmer Vernooij)
93
94+ * Backslash (\) is no longer accepted as a path separator
95+ on platforms where it is not the default path separator,
96+ e.g. POSIX systems. This is so that filenames with backslashes
97+ in their name can be added explicitly. (#176263, #165151)
98+
99 * One-letter shortcuts for Ubuntu releases are no
100 longer supported after 'ubuntu:'. Bazaar's mapping for
101 one-letter distroseries had not been updated since natty.
102@@ -176,6 +181,10 @@
103
104 * Support '0' markers in fastimport plugin. (Jelmer Vernooij, #1744615)
105
106+* Support adding/removing filenames that consist of just
107+ backslashes in where backslash is not the path separator.
108+ (Jelmer Vernooij, #176263, #165151)
109+
110 * Report correct path in output of ``brz add``.
111 (Brian de Alwis, Jelmer Vernooij, #1799482)
112

Subscribers

People subscribed via source and target branches