Rev 4801: (Gordon Tyler) Fix IndexError during 'bzr ignore /' (#456036) in file:///home/pqm/archives/thelove/bzr/%2Btrunk/
Canonical.com Patch Queue Manager
pqm at pqm.ubuntu.com
Tue Nov 17 03:20:36 GMT 2009
At file:///home/pqm/archives/thelove/bzr/%2Btrunk/
------------------------------------------------------------
revno: 4801 [merge]
revision-id: pqm at pqm.ubuntu.com-20091117032035-s3sgtlixj1lrminn
parent: pqm at pqm.ubuntu.com-20091116224254-fgspnq9xz29z662j
parent: andrew.bennetts at canonical.com-20091117023442-8vioar3w20x2y7b5
committer: Canonical.com Patch Queue Manager <pqm at pqm.ubuntu.com>
branch nick: +trunk
timestamp: Tue 2009-11-17 03:20:35 +0000
message:
(Gordon Tyler) Fix IndexError during 'bzr ignore /' (#456036)
modified:
NEWS NEWS-20050323055033-4e00b5db738777ff
bzrlib/globbing.py glob.py-20061113075651-q63o2v35fm2ydk9x-1
bzrlib/tests/test_globbing.py test_glob.py-20061113075651-q63o2v35fm2ydk9x-2
=== modified file 'NEWS'
--- a/NEWS 2009-11-16 20:50:41 +0000
+++ b/NEWS 2009-11-17 02:34:42 +0000
@@ -19,10 +19,13 @@
Bug Fixes
*********
+
* After renaming a file, the dirstate could accidentally reference
``source\\path`` rather than ``source/path`` on Windows. This might be a
source of some dirstate-related failures. (John Arbash Meinel)
+* ``bzr ignore /`` no longer causes an IndexError. (Gorder Tyler, #456036)
+
* Lots of bugfixes for the test suite on Windows. We should once again
have a test suite with no failures on Windows. (Once all the patches
have landed, remove this line.) (John Arbash Meinel)
=== modified file 'bzrlib/globbing.py'
--- a/bzrlib/globbing.py 2009-03-23 14:59:43 +0000
+++ b/bzrlib/globbing.py 2009-11-11 21:38:02 +0000
@@ -238,11 +238,15 @@
prefix=r'(?:.*/)?(?!.*/)')
+_slashes = re.compile(r'[\\/]+')
def normalize_pattern(pattern):
"""Converts backslashes in path patterns to forward slashes.
Doesn't normalize regular expressions - they may contain escapes.
"""
+
if not pattern.startswith('RE:'):
- pattern = pattern.replace('\\','/')
- return pattern.rstrip('/')
+ pattern = _slashes.sub('/', pattern)
+ if len(pattern) > 1:
+ pattern = pattern.rstrip('/')
+ return pattern
=== modified file 'bzrlib/tests/test_globbing.py'
--- a/bzrlib/tests/test_globbing.py 2009-03-23 14:59:43 +0000
+++ b/bzrlib/tests/test_globbing.py 2009-11-11 21:38:02 +0000
@@ -18,6 +18,7 @@
from bzrlib.globbing import (
Globster,
_OrderedGlobster,
+ normalize_pattern
)
from bzrlib.tests import (
TestCase,
@@ -318,3 +319,30 @@
globster = _OrderedGlobster(reversed(patterns))
self.assertEqual(u'bar.*', globster.match('bar.foo'))
self.assertEqual(None, globster.match('foo.bar'))
+
+
+class TestNormalizePattern(TestCase):
+
+ def test_backslashes(self):
+ """tests that backslashes are converted to forward slashes, multiple
+ backslashes are collapsed to single forward slashes and trailing
+ backslashes are removed"""
+ self.assertEqual(u'/', normalize_pattern(u'\\'))
+ self.assertEqual(u'/', normalize_pattern(u'\\\\'))
+ self.assertEqual(u'/foo/bar', normalize_pattern(u'\\foo\\bar'))
+ self.assertEqual(u'foo/bar', normalize_pattern(u'foo\\bar\\'))
+ self.assertEqual(u'/foo/bar', normalize_pattern(u'\\\\foo\\\\bar\\\\'))
+
+ def test_forward_slashes(self):
+ """tests that multiple foward slashes are collapsed to single forward
+ slashes and trailing forward slashes are removed"""
+ self.assertEqual(u'/', normalize_pattern(u'/'))
+ self.assertEqual(u'/', normalize_pattern(u'//'))
+ self.assertEqual(u'/foo/bar', normalize_pattern(u'/foo/bar'))
+ self.assertEqual(u'foo/bar', normalize_pattern(u'foo/bar/'))
+ self.assertEqual(u'/foo/bar', normalize_pattern(u'//foo//bar//'))
+
+ def test_mixed_slashes(self):
+ """tests that multiple mixed slashes are collapsed to single forward
+ slashes and trailing mixed slashes are removed"""
+ self.assertEqual(u'/foo/bar', normalize_pattern(u'\\/\\foo//\\///bar/\\\\/'))
More information about the bazaar-commits
mailing list