Commit 4ca33fa6 authored by Martijn Pieters's avatar Martijn Pieters
Browse files

format-source: skip symlinked files

parent d7528062f574
......@@ -129,7 +129,11 @@
# perform actual formatting
for filepath in wctx.matches(matcher):
flags = wctx.flags(filepath)
if 'l' in flags:
# links should just be skipped
ui.warn(_('Skipping symlink, %s\n') % filepath)
continue
newcontent = run_tools(ui, repo.root, tool, shell_tool, filepath, filepath)
# XXX we could do the whole commit in memory
with repo.wvfs(filepath, 'wb') as formatted_file:
formatted_file.write(newcontent)
......@@ -132,8 +136,8 @@
newcontent = run_tools(ui, repo.root, tool, shell_tool, filepath, filepath)
# XXX we could do the whole commit in memory
with repo.wvfs(filepath, 'wb') as formatted_file:
formatted_file.write(newcontent)
wctx.filectx(filepath).setflags('l' in flags, 'x' in flags)
wctx.filectx(filepath).setflags(False, 'x' in flags)
# update the storage to mark formated file as formatted
with repo.wvfs(file_storage_path, mode='ab') as storage:
......
......@@ -1290,6 +1290,6 @@
==============
$ mkdir flags
$ cat << EOF > flags/executable.json
$ cat << EOF > flags/linktarget.txt
> {}
> EOF
......@@ -1294,6 +1294,8 @@
> {}
> EOF
$ ln -s flags/linktarget.txt flags/linked.json
$ cp flags/linktarget.txt flags/executable.json
$ chmod +x flags/executable.json
$ hg add -q flags/*
$ hg ci -qm "Add flags subdir"
$ hg format-source json glob:flags/* -m 'Executable file formatted'
......@@ -1296,6 +1298,7 @@
$ chmod +x flags/executable.json
$ hg add -q flags/*
$ hg ci -qm "Add flags subdir"
$ hg format-source json glob:flags/* -m 'Executable file formatted'
Skipping symlink, flags/linked.json
$ ls -l flags/* | cut -b 1-10
-rwxr-xr-x
......@@ -1300,5 +1303,7 @@
$ ls -l flags/* | cut -b 1-10
-rwxr-xr-x
lrwxr-xr-x
-rw-r--r--
Test error case
===============
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment