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

Proposed by Jelmer Vernooij
Status: Merged
Approved by: Jelmer Vernooij
Approved revision: no longer in the source branch.
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 Approve
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.
Revision history for this message
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.

Revision history for this message
The Breezy Bot (the-breezy-bot) wrote :
Revision history for this message
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

Revision history for this message
Martin Packman (gz) wrote :

Okay, lets do it.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'breezy/osutils.py'
--- breezy/osutils.py 2018-11-12 01:41:38 +0000
+++ breezy/osutils.py 2018-11-17 18:51:40 +0000
@@ -1035,12 +1035,18 @@
10351035
1036def splitpath(p):1036def splitpath(p):
1037 """Turn string into list of parts."""1037 """Turn string into list of parts."""
1038 # split on either delimiter because people might use either on1038 if os.path.sep == '\\':
1039 # Windows1039 # split on either delimiter because people might use either on
1040 if isinstance(p, bytes):1040 # Windows
1041 ps = re.split(b'[\\\\/]', p)1041 if isinstance(p, bytes):
1042 ps = re.split(b'[\\\\/]', p)
1043 else:
1044 ps = re.split(r'[\\/]', p)
1042 else:1045 else:
1043 ps = re.split(r'[\\/]', p)1046 if isinstance(p, bytes):
1047 ps = p.split(b'/')
1048 else:
1049 ps = p.split('/')
10441050
1045 rps = []1051 rps = []
1046 for f in ps:1052 for f in ps:
10471053
=== modified file 'breezy/tests/blackbox/test_add.py'
--- breezy/tests/blackbox/test_add.py 2018-11-11 04:08:32 +0000
+++ breezy/tests/blackbox/test_add.py 2018-11-17 18:51:40 +0000
@@ -265,3 +265,16 @@
265 out = self.run_bzr('add')[0]265 out = self.run_bzr('add')[0]
266 results = sorted(out.rstrip('\n').split('\n'))266 results = sorted(out.rstrip('\n').split('\n'))
267 self.assertEqual(['adding big.txt'], results)267 self.assertEqual(['adding big.txt'], results)
268
269 def test_add_backslash(self):
270 # pad.lv/165151
271 if os.path.sep == '\\':
272 # TODO(jelmer): Test that backslashes are appropriately
273 # ignored?
274 raise tests.TestNotApplicable(
275 'unable to add filenames with backslashes where '
276 ' it is the path separator')
277 tree = self.make_branch_and_tree('.')
278 self.build_tree(['\\'])
279 self.assertEqual('adding \\\n', self.run_bzr('add \\\\')[0])
280 self.assertEqual('\\\n', self.run_bzr('ls --versioned')[0])
268281
=== modified file 'breezy/tests/blackbox/test_remove.py'
--- breezy/tests/blackbox/test_remove.py 2018-11-11 04:08:32 +0000
+++ breezy/tests/blackbox/test_remove.py 2018-11-17 18:51:40 +0000
@@ -274,3 +274,16 @@
274 error_regexes=["removed a", "removed b", "removed b/c"])274 error_regexes=["removed a", "removed b", "removed b/c"])
275 tree = WorkingTree.open('.')275 tree = WorkingTree.open('.')
276 self.assertFilesUnversioned(files)276 self.assertFilesUnversioned(files)
277
278 def test_remove_backslash(self):
279 # pad.lv/176263
280 if os.path.sep == '\\':
281 raise tests.TestNotApplicable(
282 'unable to add filenames with backslashes where '
283 ' it is the path separator')
284 tree = self.make_branch_and_tree('.')
285 self.build_tree(['\\'])
286 self.assertEqual('adding \\\n', self.run_bzr('add \\\\')[0])
287 self.assertEqual('\\\n', self.run_bzr('ls --versioned')[0])
288 self.assertEqual('', self.run_bzr('rm \\\\')[0])
289 self.assertEqual('', self.run_bzr('ls --versioned')[0])
277290
=== modified file 'breezy/tests/test_osutils.py'
--- breezy/tests/test_osutils.py 2018-11-12 01:41:38 +0000
+++ breezy/tests/test_osutils.py 2018-11-17 18:51:40 +0000
@@ -1058,7 +1058,10 @@
1058 check(['a', 'b'], 'a/b')1058 check(['a', 'b'], 'a/b')
1059 check(['a', 'b'], 'a/./b')1059 check(['a', 'b'], 'a/./b')
1060 check(['a', '.b'], 'a/.b')1060 check(['a', '.b'], 'a/.b')
1061 check(['a', '.b'], 'a\\.b')1061 if os.path.sep == '\\':
1062 check(['a', '.b'], 'a\\.b')
1063 else:
1064 check(['a\\.b'], 'a\\.b')
10621065
1063 self.assertRaises(errors.BzrError, osutils.splitpath, 'a/../b')1066 self.assertRaises(errors.BzrError, osutils.splitpath, 'a/../b')
10641067
10651068
=== modified file 'doc/en/release-notes/brz-3.0.txt'
--- doc/en/release-notes/brz-3.0.txt 2018-11-16 07:18:33 +0000
+++ doc/en/release-notes/brz-3.0.txt 2018-11-17 18:51:40 +0000
@@ -67,6 +67,11 @@
67 has been renamed to ``transform.orphan_policy``.67 has been renamed to ``transform.orphan_policy``.
68 (Jelmer Vernooij)68 (Jelmer Vernooij)
6969
70 * Backslash (\) is no longer accepted as a path separator
71 on platforms where it is not the default path separator,
72 e.g. POSIX systems. This is so that filenames with backslashes
73 in their name can be added explicitly. (#176263, #165151)
74
70 * One-letter shortcuts for Ubuntu releases are no75 * One-letter shortcuts for Ubuntu releases are no
71 longer supported after 'ubuntu:'. Bazaar's mapping for76 longer supported after 'ubuntu:'. Bazaar's mapping for
72 one-letter distroseries had not been updated since natty.77 one-letter distroseries had not been updated since natty.
@@ -176,6 +181,10 @@
176181
177* Support '0' markers in fastimport plugin. (Jelmer Vernooij, #1744615)182* Support '0' markers in fastimport plugin. (Jelmer Vernooij, #1744615)
178183
184* Support adding/removing filenames that consist of just
185 backslashes in where backslash is not the path separator.
186 (Jelmer Vernooij, #176263, #165151)
187
179* Report correct path in output of ``brz add``.188* Report correct path in output of ``brz add``.
180 (Brian de Alwis, Jelmer Vernooij, #1799482)189 (Brian de Alwis, Jelmer Vernooij, #1799482)
181190

Subscribers

People subscribed via source and target branches