# HG changeset patch # User Nikita Slyusarev # Date 1549565330 -10800 # Node ID 36ee0d6d64c5b1b341922536519fb4c699399c65 # Parent 2c13e91ede6e646aa667be722b02375368df9187 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. diff -r 2c13e91ede6e -r 36ee0d6d64c5 hgext/convert/subversion.py --- 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: diff -r 2c13e91ede6e -r 36ee0d6d64c5 tests/test-convert-svn-sink.t --- a/tests/test-convert-svn-sink.t Thu Feb 07 18:57:54 2019 +0300 +++ b/tests/test-convert-svn-sink.t Thu Feb 07 21:48:50 2019 +0300 @@ -467,6 +467,45 @@ A /a $ rm -rf a a-hg a-hg-wc +#if execbit + +Executable bit removal + + $ hg init a + + $ echo a > a/exec + $ chmod +x a/exec + $ hg --cwd a ci -d '1 0' -A -m 'create executable' + adding exec + $ chmod -x a/exec + $ hg --cwd a ci -d '2 0' -A -m 'remove executable bit' + + $ hg convert -d svn a + assuming destination a-hg + initializing svn repository 'a-hg' + initializing svn working copy 'a-hg-wc' + scanning source... + sorting... + converting... + 1 create executable + 0 remove executable bit + $ svnupanddisplay a-hg-wc 0 + 2 2 test . + 2 2 test exec + revision: 2 + author: test + msg: remove executable bit + M /exec + revision: 1 + author: test + msg: create executable + A /exec + $ test ! -x a-hg-wc/exec + + $ rm -rf a a-hg a-hg-wc + +#endif + Skipping empty commits $ hg init a