[MERGE] Mark .bzr directories as "hidden" on Windows (#71147)
Alexander Belchenko
bialix at ukr.net
Mon Nov 26 18:26:36 GMT 2007
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
John Arbash Meinel пишет:
> John Arbash Meinel has voted tweak.
> Status is now: Conditionally approved
> Comment:
> I would be more comfortable with using a list and subprocess.Popen()
> such as:
>
> +class TestDotBzrHidden(TestCaseWithTransport):
> +
>
> + ls = ['ls']
> + if sys.platform == 'win32':
> + ls = [os.environ['COMSPEC'], '/C', 'dir', '/B']
> +
> + def get_ls(self):
> + f = subprocess.Popen(self.ls, stdout=subprocess.PIPE)
> + out, err = f.communicate()
> self.assertEqual(0, f.returncode, 'Calling %s failed: %s'
> % (self.ls, err))
> out_lines = out.splitlines()
> ...
OK. NP.
os.popen just seems simpler to use.
> Also, I don't see the code where set_file_attr_hidden(path) is actually
> being used. So I'm not sure why the tests are passing on Windows, since
> it doesn't seem to actually make the file hidden.
It used in bzrdir.py: class BzrDirFormat: method initialize_on_transport.
Here is corresponding hunk of patch:
@@ -1355,6 +1357,8 @@
# FIXME: RBC 20060121 don't peek under
# the covers
mode=temp_control._dir_mode)
+ if sys.platform == 'win32' and isinstance(transport, LocalTransport):
+ win32utils.set_file_attr_hidden(transport._abspath('.bzr'))
file_mode = temp_control._file_mode
del temp_control
mutter('created control directory in ' + transport.base)
Here is full text:
def initialize_on_transport(self, transport):
"""Initialize a new bzrdir in the base directory of a Transport."""
# Since we don't have a .bzr directory, inherit the
# mode from the root directory
temp_control = lockable_files.LockableFiles(transport,
'', lockable_files.TransportLock)
temp_control._transport.mkdir('.bzr',
# FIXME: RBC 20060121 don't peek under
# the covers
mode=temp_control._dir_mode)
if sys.platform == 'win32' and isinstance(transport, LocalTransport):
win32utils.set_file_attr_hidden(transport._abspath('.bzr'))
^-- Last 2 lines do the job.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
iD8DBQFHSw/czYr338mxwCURAqz4AKCH+56DUUcbSa9iMVJGEZLKSiG4ewCgl43V
sGL4oesLIgFnmoq6E1VG3s4=
=tLpr
-----END PGP SIGNATURE-----
More information about the bazaar
mailing list