remote-hg: fix handling of file perms when pushing

Previously, when changing and committing an executable file, the file would loose its executable bit on the hg side. Likewise, symlinks ended up as "normal" files". This was not immediately apparent on the git side unless one did a fresh clone. Signed-off-by: Max Horn <max@quendi.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Max Horn committed Jan 15, 2013 at 14:02 UTC 3968e302f8d09104da9ede15079f1133df6d3b68
2 files changed +69 -1
contrib/remote-helpers/git-remote-hg
+1 -1
@@ -53,7 +53,7 @@ def gittz(tz):
53 return '%+03d%02d' % (-tz / 3600, -tz % 3600 / 60)
54
55 def hgmode(mode):
56 - m = { '0100755': 'x', '0120000': 'l' }
56 + m = { '100755': 'x', '120000': 'l' }
57 return m.get(mode, '')
58
59 def get_config(config):
contrib/remote-helpers/test-hg-hg-git.sh
+68
@@ -109,6 +109,74 @@ setup () {
109
110 setup
111
112 +test_expect_success 'executable bit' '
113 + mkdir -p tmp && cd tmp &&
114 + test_when_finished "cd .. && rm -rf tmp" &&
115 +
116 + (
117 + git init -q gitrepo &&
118 + cd gitrepo &&
119 + echo alpha > alpha &&
120 + chmod 0644 alpha &&
121 + git add alpha &&
122 + git commit -m "add alpha" &&
123 + chmod 0755 alpha &&
124 + git add alpha &&
125 + git commit -m "set executable bit" &&
126 + chmod 0644 alpha &&
127 + git add alpha &&
128 + git commit -m "clear executable bit"
129 + ) &&
130 +
131 + for x in hg git; do
132 + (
133 + hg_clone_$x gitrepo hgrepo-$x &&
134 + cd hgrepo-$x &&
135 + hg_log . &&
136 + hg manifest -r 1 -v &&
137 + hg manifest -v
138 + ) > output-$x &&
139 +
140 + git_clone_$x hgrepo-$x gitrepo2-$x &&
141 + git_log gitrepo2-$x > log-$x
142 + done &&
143 + cp -r log-* output-* /tmp/foo/ &&
144 +
145 + test_cmp output-hg output-git &&
146 + test_cmp log-hg log-git
147 +'
148 +
149 +test_expect_success 'symlink' '
150 + mkdir -p tmp && cd tmp &&
151 + test_when_finished "cd .. && rm -rf tmp" &&
152 +
153 + (
154 + git init -q gitrepo &&
155 + cd gitrepo &&
156 + echo alpha > alpha &&
157 + git add alpha &&
158 + git commit -m "add alpha" &&
159 + ln -s alpha beta &&
160 + git add beta &&
161 + git commit -m "add beta"
162 + ) &&
163 +
164 + for x in hg git; do
165 + (
166 + hg_clone_$x gitrepo hgrepo-$x &&
167 + cd hgrepo-$x &&
168 + hg_log . &&
169 + hg manifest -v
170 + ) > output-$x &&
171 +
172 + git_clone_$x hgrepo-$x gitrepo2-$x &&
173 + git_log gitrepo2-$x > log-$x
174 + done &&
175 +
176 + test_cmp output-hg output-git &&
177 + test_cmp log-hg log-git
178 +'
179 +
180 test_expect_success 'merge conflict 1' '
181 mkdir -p tmp && cd tmp &&
182 test_when_finished "cd .. && rm -rf tmp" &&