Mercurial > public > mercurial-scm > hg-stable
diff hgext/extdiff.py @ 8065:66d0a03d3afc
extdiff: preserve execute-bit across copies (issue1562)
Bug report and test by Mads Kiilerich <mads@kiilerich.com>
author | Patrick Mezard <pmezard@gmail.com> |
---|---|
date | Thu, 09 Apr 2009 14:32:44 +0200 |
parents | 5c7bc1aece9e |
children | aece3c9e62f1 |
line wrap: on
line diff
--- a/hgext/extdiff.py Mon Apr 13 21:21:01 2009 +0200 +++ b/hgext/extdiff.py Thu Apr 09 14:32:44 2009 +0200 @@ -67,7 +67,7 @@ else: ui.note(_('making snapshot of %d files from working dir\n') % (len(files))) - + wopener = util.opener(base) fns_and_mtime = [] ctx = repo[node] for fn in files: @@ -77,11 +77,14 @@ continue ui.note(' %s\n' % wfn) dest = os.path.join(base, wfn) - destdir = os.path.dirname(dest) - if not os.path.isdir(destdir): - os.makedirs(destdir) - data = repo.wwritedata(wfn, ctx[wfn].data()) - open(dest, 'wb').write(data) + fctx = ctx[wfn] + data = repo.wwritedata(wfn, fctx.data()) + if 'l' in fctx.flags(): + wopener.symlink(data, wfn) + else: + wopener(wfn, 'w').write(data) + if 'x' in fctx.flags(): + util.set_flags(dest, False, True) if node is None: fns_and_mtime.append((dest, repo.wjoin(fn), os.path.getmtime(dest))) return dirname, fns_and_mtime