[Pkg-bazaar-commits] ./bzr/unstable r271: - Windows path fixes
Martin Pool
mbp at sourcefrog.net
Fri Apr 10 07:43:53 UTC 2009
------------------------------------------------------------
revno: 271
committer: Martin Pool <mbp at sourcefrog.net>
timestamp: Fri 2005-04-15 17:53:59 +1000
message:
- Windows path fixes
modified:
bzrlib/commands.py
bzrlib/inventory.py
bzrlib/osutils.py
bzrlib/textui.py
bzrlib/tree.py
-------------- next part --------------
=== modified file 'bzrlib/commands.py'
--- a/bzrlib/commands.py 2005-04-15 03:28:59 +0000
+++ b/bzrlib/commands.py 2005-04-15 07:53:59 +0000
@@ -374,12 +374,15 @@
# TODO: Better to return them in sorted order I think.
+ if file_list:
+ file_list = [b.relpath(f) for f in file_list]
+
# FIXME: If given a file list, compare only those files rather
# than comparing everything and then throwing stuff away.
for file_state, fid, old_name, new_name, kind in bzrlib.diff_trees(old_tree, new_tree):
- if file_list and new_name not in file_list:
+ if file_list and (new_name not in file_list):
continue
# Don't show this by default; maybe do it if an option is passed
=== modified file 'bzrlib/inventory.py'
--- a/bzrlib/inventory.py 2005-04-15 01:31:21 +0000
+++ b/bzrlib/inventory.py 2005-04-15 07:53:59 +0000
@@ -343,7 +343,7 @@
yield name, ie
if ie.kind == 'directory':
for cn, cie in self.iter_entries(from_dir=ie.file_id):
- yield '/'.join((name, cn)), cie
+ yield os.path.join(name, cn), cie
@@ -555,7 +555,7 @@
# get all names, skipping root
p = [self[fid].name for fid in self.get_idpath(file_id)[1:]]
- return '/'.join(p)
+ return os.sep.join(p)
=== modified file 'bzrlib/osutils.py'
--- a/bzrlib/osutils.py 2005-04-15 02:34:07 +0000
+++ b/bzrlib/osutils.py 2005-04-15 07:53:59 +0000
@@ -319,25 +319,34 @@
BzrError: ("sorry, '..' not allowed in path", [])
"""
assert isinstance(p, types.StringTypes)
- ps = [f for f in p.split('/') if (f != '.' and f != '')]
+
+ # split on either delimiter because people might use either on
+ # Windows
+ ps = re.split(r'[\\/]', p)
+
+ rps = []
for f in ps:
if f == '..':
bailout("sorry, %r not allowed in path" % f)
- return ps
+ elif (f == '.') or (f == ''):
+ pass
+ else:
+ rps.append(f)
+ return rps
def joinpath(p):
assert isinstance(p, list)
for f in p:
if (f == '..') or (f == None) or (f == ''):
bailout("sorry, %r not allowed in path" % f)
- return '/'.join(p)
+ return os.path.join(*p)
def appendpath(p1, p2):
if p1 == '':
return p2
else:
- return p1 + '/' + p2
+ return os.path.join(p1, p2)
def extern_command(cmd, ignore_errors = False):
=== modified file 'bzrlib/textui.py'
--- a/bzrlib/textui.py 2005-03-09 04:08:15 +0000
+++ b/bzrlib/textui.py 2005-04-15 07:53:59 +0000
@@ -19,6 +19,7 @@
def show_status(state, kind, name):
if kind == 'directory':
+ # use this even on windows?
kind_ch = '/'
else:
assert kind == 'file'
=== modified file 'bzrlib/tree.py'
--- a/bzrlib/tree.py 2005-04-15 01:31:21 +0000
+++ b/bzrlib/tree.py 2005-04-15 07:53:59 +0000
@@ -304,22 +304,32 @@
def is_ignored(self, filename):
- """Check whether the filename matches an ignore pattern.
+ r"""Check whether the filename matches an ignore pattern.
- Patterns containing '/' need to match the whole path; others
- match against only the last component.
+ Patterns containing '/' or '\' need to match the whole path;
+ others match against only the last component.
If the file is ignored, returns the pattern which caused it to
be ignored, otherwise None. So this can simply be used as a
boolean if desired."""
- ## TODO: Use '**' to match directories, and other extended globbing stuff from cvs/rsync.
+ # TODO: Use '**' to match directories, and other extended
+ # globbing stuff from cvs/rsync.
+
+ # XXX: fnmatch is actually not quite what we want: it's only
+ # approximately the same as real Unix fnmatch, and doesn't
+ # treat dotfiles correctly and allows * to match /.
+ # Eventually it should be replaced with something more
+ # accurate.
for pat in self.get_ignore_list():
- if '/' in pat:
- # as a special case, you can put ./ at the start of a pattern;
- # this is good to match in the top-level only;
- if pat[:2] == './':
+ if '/' in pat or '\\' in pat:
+
+ # as a special case, you can put ./ at the start of a
+ # pattern; this is good to match in the top-level
+ # only;
+
+ if (pat[:2] == './') or (pat[:2] == '.\\'):
newpat = pat[2:]
else:
newpat = pat
More information about the Pkg-bazaar-commits
mailing list