Merge lp:~gz/bzr-git/import_os_not_posix_841177 into lp:bzr-git

Proposed by Martin Packman
Status: Merged
Merged at revision: 1357
Proposed branch: lp:~gz/bzr-git/import_os_not_posix_841177
Merge into: lp:bzr-git
Diff against target: 53 lines (+18/-0) (has conflicts)
1 file modified
workingtree.py (+18/-0)
Text conflict in workingtree.py
To merge this branch: bzr merge lp:~gz/bzr-git/import_os_not_posix_841177
Reviewer Review Type Date Requested Status
bzr-git developers Pending
Review via email: mp+74023@code.launchpad.net

Description of the change

Makes bzr-git stick to the `os` module, which is a platform independent wrapper for the builtin `posix`, `nt` and so on modules. There is no behaviour change here, apart from making the module importable on non-posix systems.

I resisted changing `posixpath` usage into `os.path` because it's not trivial to tell which is actually desired. Paths from the filesystem should be operated on with `os.path` but normalized bzrlib paths that use forward slashes only can use most of the posixpath functions safely.

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

To answer a query from IRC, stat_result doesn't have different content or behaviour in the cases here. See statresult_new in Modules/posixmodules.c which is pretty straight forward. (The module source confusingly has 'posix' in the name but is cross-platform code, and results in a module named after the platform).

The conflicts with trunk are a little crazy, but should be easy enough to resolve correctly now.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'workingtree.py'
--- workingtree.py 2011-09-04 18:33:18 +0000
+++ workingtree.py 2011-09-04 18:42:40 +0000
@@ -34,7 +34,11 @@
34 ZERO_SHA,34 ZERO_SHA,
35 )35 )
36import os36import os
37<<<<<<< TREE
37from posix import stat_result38from posix import stat_result
39=======
40# GZ 2011-09-04: Should use os.path instead unless certain of posix format.
41>>>>>>> MERGE-SOURCE
38import posixpath42import posixpath
39import stat43import stat
40import sys44import sys
@@ -131,7 +135,12 @@
131 except (errors.NoSuchFile, IOError):135 except (errors.NoSuchFile, IOError):
132 # TODO: Rather than come up with something here, use the old index136 # TODO: Rather than come up with something here, use the old index
133 file = StringIO()137 file = StringIO()
138<<<<<<< TREE
134 stat_val = stat_result((stat.S_IFREG | 0644, 0, 0, 0, 0, 0, 0, 0, 0, 0))139 stat_val = stat_result((stat.S_IFREG | 0644, 0, 0, 0, 0, 0, 0, 0, 0, 0))
140=======
141 stat_val = os.stat_result(
142 (stat.S_IFREG | 0644, 0, 0, 0, 0, 0, 0, 0, 0, 0))
143>>>>>>> MERGE-SOURCE
135 blob.set_raw_string(file.read())144 blob.set_raw_string(file.read())
136 elif kind == "symlink":145 elif kind == "symlink":
137 blob = Blob()146 blob = Blob()
@@ -140,7 +149,12 @@
140 except (errors.NoSuchFile, OSError):149 except (errors.NoSuchFile, OSError):
141 # TODO: Rather than come up with something here, use the 150 # TODO: Rather than come up with something here, use the
142 # old index151 # old index
152<<<<<<< TREE
143 stat_val = stat_result((stat.S_IFLNK, 0, 0, 0, 0, 0, 0, 0, 0, 0))153 stat_val = stat_result((stat.S_IFLNK, 0, 0, 0, 0, 0, 0, 0, 0, 0))
154=======
155 stat_val = os.stat_result(
156 (stat.S_IFLNK, 0, 0, 0, 0, 0, 0, 0, 0, 0))
157>>>>>>> MERGE-SOURCE
144 blob.set_raw_string(158 blob.set_raw_string(
145 self.get_symlink_target(file_id, path).encode("utf-8"))159 self.get_symlink_target(file_id, path).encode("utf-8"))
146 else:160 else:
@@ -695,7 +709,11 @@
695 dir_file_id = self.path2id(dirname)709 dir_file_id = self.path2id(dirname)
696 assert isinstance(value, tuple) and len(value) == 10710 assert isinstance(value, tuple) and len(value) == 10
697 (ctime, mtime, dev, ino, mode, uid, gid, size, sha, flags) = value711 (ctime, mtime, dev, ino, mode, uid, gid, size, sha, flags) = value
712<<<<<<< TREE
698 stat_result = stat_result((mode, ino,713 stat_result = stat_result((mode, ino,
714=======
715 stat_result = os.stat_result((mode, ino,
716>>>>>>> MERGE-SOURCE
699 dev, 1, uid, gid, size,717 dev, 1, uid, gid, size,
700 0, mtime, ctime))718 0, mtime, ctime))
701 per_dir[(dirname, dir_file_id)].append(719 per_dir[(dirname, dir_file_id)].append(

Subscribers

People subscribed via source and target branches

to all changes: