Mercurial > hg
diff hgext/convert/subversion.py @ 41617:36ee0d6d64c5
convert: handle exec bit removal while converting to svn
Subversion `putcommit` method checks original file's executablity to decide
if executable property should be removed from svn. It is checked right after
writing file contents.
Content writing is implemented using `vfs.write` and vfs seems to remove exec
bit, at least in some cases. This leads to executability checks being
ineffective. If cset contains only this ignored exec bit removal, conversion
stops with an error, because it fails to to compose svn commit properly.
This fix moves exec bit checking so that it's performed before dumping file
contents.
Added test to check executable bit removal.
author | Nikita Slyusarev <nslus@yandex-team.com> |
---|---|
date | Thu, 07 Feb 2019 21:48:50 +0300 |
parents | 2c13e91ede6e |
children | aaad36b88298 |
line wrap: on
line diff
--- a/hgext/convert/subversion.py Thu Feb 07 18:57:54 2019 +0300 +++ b/hgext/convert/subversion.py Thu Feb 07 21:48:50 2019 +0300 @@ -1206,10 +1206,18 @@ os.unlink(filename) except OSError: pass + + if self.is_exec: + # We need to check executability of the file before the change, + # because `vfs.write` is able to reset exec bit. + wasexec = False + if os.path.exists(self.wjoin(filename)): + wasexec = self.is_exec(self.wjoin(filename)) + self.wopener.write(filename, data) if self.is_exec: - if self.is_exec(self.wjoin(filename)): + if wasexec: if 'x' not in flags: self.delexec.append(filename) else: