[MERGE] Fix ftp transport so that it handles the 'mode' parameter when provided.
John Arbash Meinel
john at arbash-meinel.com
Fri Jun 27 20:10:30 BST 2008
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Vincent Ladeuil wrote:
| This patch slightly modifies the ftp transport to handle chmod.
|
| I needed it for the bzr-upload plugin whose main aim is to
| maintain remote working trees.
|
| This is achieved by issuing SITE CHMOD commands. This is not
| supported by all servers so I let it fail silently (modulo a
| warning which goes to .bzr.log as the actual version does) when
| the command is not available.
|
| We may want to issue that warning it only once, but since this is
| not used by bzr itself, I'm not sure it's worth the effort.
|
| I also updated our ftp test server to implement it.
|
| I didn't define _can_roundtrip_unix_modebits though as I realized
| that this can't be implemented by the transport alone.
|
| At least in the ftp case, both the transport and the server
| should be invoked to.. roundtrip them :)
|
| Thoughts ? Do we want to test some combinations here ? I realize
| that skip some tests, but I can give it a try.
|
| I may continue working on the ftp transport (I started a loom and
| this is the first thread) once I calm down a bit (ftp made me
| wish I had still hairs :-)
|
| So, as this is not worse that what we have today, I'd like to
| merge it to address bzr-upload needs.
|
| Vincent
|
| P.S.: I didn't put an entry in NEWS because... well, bzrlib is
| concerned, not bzr itself, I didn't filed a bug, I don't really
| know where to put it nor if it's worth it.
|
|
+class test_filesystem(medusa.filesys.os_filesystem):
+ """A custom filesystem wrapper to add missing functionalities."""
+
+ def chmod(self, path, mode):
+ p = self.normalize (self.path_module.join (self.wd, path))
+ return os.chmod(self.translate(p), mode)
^- 'self.normalize ()' is not our standard syntax.
+ def cmd_site(self, line):
+ command, args = line[1].split(' ', 1)
+ if command.lower() == 'chmod':
+ try:
+ mode, path = args.split()
+ mode = int(mode, 8)
+ except ValueError:
+ self.command_not_understood(' '.join(line))
+ return
+ try:
+ # Yes path and mode are reversed
+ self.filesystem.chmod(path, mode)
+ self.respond('200 SITE CHMOD command successful')
+ except AttributeError:
+ # The chmod method is not available in read-only
+ self.command_not_authorized(' '.join(line))
+ else:
+ self.command_not_understood(' '.join(line))
+
^- Is this the fallback, or do you need to call back into the original
handler?
I think if our test setup can "roundtrip_unix_mode_bits" then we should
be setting this to True, so that we can have them tested in the test
suite. Though you would still need a win32 check since you still can't
round-trip them if the underlying fs doesn't support it.
Otherwise, I think it is a simple:
BB:tweak
John
=:->
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (Cygwin)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
iEYEARECAAYFAkhlOyYACgkQJdeBCYSNAANq3gCfV9/AjcQcu96oQMvKNr94BmUu
tgIAn2EDIk9iJe1ei3PoQ3cPzbaLRDQ9
=SxE1
-----END PGP SIGNATURE-----
More information about the bazaar
mailing list