whitespace normalization pre-commit hook is giving me grief
In my bcannon-objcap branch I am trying to check in a change that involves a soft symlink from Lib/controlled_importlib.py to ../importlib/controlled_importlib.py through ``ln -s ../controlled_importlib.py controlled_importlib.py`` while in the Lib directory. I have done this before in this branch so as to allow for easy importing of code from the svn import of importlib that the branch contains. But svn keeps rejecting the commit saying that Lib/controlled_importlib.py needs to be whitespace normalized. I have run reindent on both the external import in the branch and in the original sandbox copy and both are coming back clean. I even imported reindent manually and followed what Georg posted when the pre-commit hook was added and it still passes. Unfortunately the pre-commit hook does not specify what line a change was made on so I have no clue where it is failing (maybe this should be added?). Can somebody help me figure out what the hell is going on? I am waiting to find out it is something small and stupid, but at this point I am not seeing a solution to this. -Brett
On 5/25/07, Brett Cannon <brett@python.org> wrote:
In my bcannon-objcap branch I am trying to check in a change that involves a soft symlink from Lib/controlled_importlib.py to ../importlib/controlled_importlib.py through ``ln -s ../controlled_importlib.py controlled_importlib.py`` while in the Lib directory. I have done this before in this branch so as to allow for easy importing of code from the svn import of importlib that the branch contains.
I don't know that we've ever tested the commit hook with a link. Maybe there is some other problem. Have you tried running reindent on the actual file (not the symlink)?
Can somebody help me figure out what the hell is going on? I am waiting to find out it is something small and stupid, but at this point I am not seeing a solution to this.
Can you check in a smaller part of the change (like leaving out the symlink)? That will at least allow you to make progress. You can send me the file if you want. I can try to look at it and see if there are any problems. n
Neal Norwitz schrieb:
On 5/25/07, Brett Cannon <brett@python.org> wrote:
In my bcannon-objcap branch I am trying to check in a change that involves a soft symlink from Lib/controlled_importlib.py to ../importlib/controlled_importlib.py through ``ln -s ../controlled_importlib.py controlled_importlib.py`` while in the Lib directory. I have done this before in this branch so as to allow for easy importing of code from the svn import of importlib that the branch contains.
I don't know that we've ever tested the commit hook with a link. Maybe there is some other problem.
The cause: For symlinks, SVN saves a file containing "link /target" and sets the "svn:special" property. Since the special file doesn't end with a newline, reindent adds that, and boom. The solution: add if fs.node_prop(txn_root, path, 'svn:special') == '*': continue in the commit hook's for loop. cheers, Georg -- Thus spake the Lord: Thou shalt indent with four spaces. No more, no less. Four shall be the number of spaces thou shalt indent, and the number of thy indenting shall be four. Eight shalt thou not indent, nor either indent thou two, excepting that thou then proceed to four. Tabs are right out.
On 5/25/07, Georg Brandl <g.brandl@gmx.net> wrote:
Neal Norwitz schrieb:
On 5/25/07, Brett Cannon <brett@python.org> wrote:
In my bcannon-objcap branch I am trying to check in a change that involves a soft symlink from Lib/controlled_importlib.py to ../importlib/controlled_importlib.py through ``ln -s ../controlled_importlib.py controlled_importlib.py`` while in the Lib directory. I have done this before in this branch so as to allow for easy importing of code from the svn import of importlib that the branch contains.
I don't know that we've ever tested the commit hook with a link. Maybe there is some other problem.
The cause: For symlinks, SVN saves a file containing "link /target" and sets the "svn:special" property. Since the special file doesn't end with a newline, reindent adds that, and boom.
The solution: add if fs.node_prop(txn_root, path, 'svn:special') == '*': continue
in the commit hook's for loop.
Great! So can someone do this? I don't know where the svn hook code is stored, let alone whether I have access to commit a change. -Brett
On 5/26/07, Brett Cannon <brett@python.org> wrote:
On 5/25/07, Georg Brandl <g.brandl@gmx.net> wrote:
Neal Norwitz schrieb:
On 5/25/07, Brett Cannon <brett@python.org> wrote:
In my bcannon-objcap branch I am trying to check in a change that involves a soft symlink from Lib/controlled_importlib.py to ../importlib/controlled_importlib.py through ``ln -s ../controlled_importlib.py controlled_importlib.py`` while in the Lib directory. I have done this before in this branch so as to allow for easy importing of code from the svn import of importlib that the branch contains.
I don't know that we've ever tested the commit hook with a link. Maybe there is some other problem.
The cause: For symlinks, SVN saves a file containing "link /target" and sets the "svn:special" property. Since the special file doesn't end with a newline, reindent adds that, and boom.
The solution: add if fs.node_prop(txn_root, path, 'svn:special') == '*': continue
in the commit hook's for loop.
Great! So can someone do this? I don't know where the svn hook code is stored, let alone whether I have access to commit a change.
I made the change Georg suggested, give it a try. n
On 5/26/07, Neal Norwitz <nnorwitz@gmail.com> wrote:
On 5/26/07, Brett Cannon <brett@python.org> wrote:
On 5/25/07, Georg Brandl <g.brandl@gmx.net> wrote:
Neal Norwitz schrieb:
On 5/25/07, Brett Cannon <brett@python.org> wrote:
In my bcannon-objcap branch I am trying to check in a change that involves a soft symlink from Lib/controlled_importlib.py to ../importlib/controlled_importlib.py through ``ln -s ../controlled_importlib.py controlled_importlib.py`` while in the
Lib
directory. I have done this before in this branch so as to allow for easy importing of code from the svn import of importlib that the branch contains.
I don't know that we've ever tested the commit hook with a link. Maybe there is some other problem.
The cause: For symlinks, SVN saves a file containing "link /target" and sets the "svn:special" property. Since the special file doesn't end with a newline, reindent adds that, and boom.
The solution: add if fs.node_prop(txn_root, path, 'svn:special') == '*': continue
in the commit hook's for loop.
Great! So can someone do this? I don't know where the svn hook code is stored, let alone whether I have access to commit a change.
I made the change Georg suggested, give it a try.
Still failing. I checked the added file for svn:special and it's set with an '*' just like my other symlink. And I double-checked the file by running ``python Tools/scripts/reindent.py -v Lib/controlled_importlib.py`` and it said nothing had changed. -Brett
On 5/25/07, Neal Norwitz <nnorwitz@gmail.com> wrote:
On 5/25/07, Brett Cannon <brett@python.org> wrote:
In my bcannon-objcap branch I am trying to check in a change that involves a soft symlink from Lib/controlled_importlib.py to ../importlib/controlled_importlib.py through ``ln -s ../controlled_importlib.py controlled_importlib.py`` while in the Lib directory. I have done this before in this branch so as to allow for easy importing of code from the svn import of importlib that the branch contains.
I don't know that we've ever tested the commit hook with a link. Maybe there is some other problem.
Have you tried running reindent on the actual file (not the symlink)?
Yes.
Can somebody help me figure out what the hell is going on? I am waiting to
find out it is something small and stupid, but at this point I am not seeing a solution to this.
Can you check in a smaller part of the change (like leaving out the symlink)? That will at least allow you to make progress.
Already did that. You can send me the file if you want. I can try to look at it and see
if there are any problems.
Looks like Georg knows the issue. -Brett
Brett Cannon schrieb:
Unfortunately the pre-commit hook does not specify what line a change was made on so I have no clue where it is failing (maybe this should be added?).
It creates a reindent.Reindenter on the new contents, then invokes .run() on it, and complains if that returns true. If you can come up with a patch to reindent that makes it report more detailed errors, please post it, and I'll try to merge it into the hook script. Regards, Martin
Martin v. Löwis wrote:
Brett Cannon schrieb:
Unfortunately the pre-commit hook does not specify what line a change was made on so I have no clue where it is failing (maybe this should be added?).
It creates a reindent.Reindenter on the new contents, then invokes .run() on it, and complains if that returns true. If you can come up with a patch to reindent that makes it report more detailed errors, please post it, and I'll try to merge it into the hook script.
How about you do: if reindenter.run(): print >>sys.stderr, "file %s is not whitespace-normalized" %path print >>sys.stderr, difflib.unified_diff(reindenter.raw, reindenter.after) bad += 1 Which would provide you a unified diff to give you a clue. -- Scott Dial scott@scottdial.com scodial@cs.indiana.edu
Scott Dial schrieb:
Martin v. Löwis wrote:
Brett Cannon schrieb:
Unfortunately the pre-commit hook does not specify what line a change was made on so I have no clue where it is failing (maybe this should be added?).
It creates a reindent.Reindenter on the new contents, then invokes .run() on it, and complains if that returns true. If you can come up with a patch to reindent that makes it report more detailed errors, please post it, and I'll try to merge it into the hook script.
How about you do:
if reindenter.run(): print >>sys.stderr, "file %s is not whitespace-normalized" %path print >>sys.stderr, difflib.unified_diff(reindenter.raw, reindenter.after) bad += 1
Which would provide you a unified diff to give you a clue.
As I said before, you don't really need that when you can (and should!) just run reindent.py over the source file yourself, not care about any diffs and just resubmit. In this particular case, the diff wouldn't have helped too, since there was no way to "fix" the SVN-generated file content... Georg -- Thus spake the Lord: Thou shalt indent with four spaces. No more, no less. Four shall be the number of spaces thou shalt indent, and the number of thy indenting shall be four. Eight shalt thou not indent, nor either indent thou two, excepting that thou then proceed to four. Tabs are right out.
As I said before, you don't really need that when you can (and should!) just run reindent.py over the source file yourself, not care about any diffs and just resubmit.
Right. So I withdraw my offer to do anything about the hook. Regards, Martin
Martin v. Löwis schrieb:
As I said before, you don't really need that when you can (and should!) just run reindent.py over the source file yourself, not care about any diffs and just resubmit.
Right. So I withdraw my offer to do anything about the hook.
I think printing something like "Please run Tools/scripts/reindent.py <file> with the rejected files" if bad files were found would be a good idea. Georg -- Thus spake the Lord: Thou shalt indent with four spaces. No more, no less. Four shall be the number of spaces thou shalt indent, and the number of thy indenting shall be four. Eight shalt thou not indent, nor either indent thou two, excepting that thou then proceed to four. Tabs are right out.
On 5/28/07, "Martin v. Löwis" <martin@v.loewis.de> wrote:
Brett Cannon schrieb:
Unfortunately the pre-commit hook does not specify what line a change was made on so I have no clue where it is failing (maybe this should be added?).
It creates a reindent.Reindenter on the new contents, then invokes .run() on it, and complains if that returns true. If you can come up with a patch to reindent that makes it report more detailed errors, please post it, and I'll try to merge it into the hook script.
The commit worked. Thanks for fixing this, Martin! And thanks to Georg for finding the initial solution. And thanks to Neal for trying Georg's initial solution. -Brett
participants (5)
-
"Martin v. Löwis"
-
Brett Cannon
-
Georg Brandl
-
Neal Norwitz
-
Scott Dial