Skip to content

Fix errors found during additional testing#30

Open
gwurster wants to merge 1 commit intomeido:masterfrom
gwurster:master
Open

Fix errors found during additional testing#30
gwurster wants to merge 1 commit intomeido:masterfrom
gwurster:master

Conversation

@gwurster
Copy link
Copy Markdown
Collaborator

This patch fixes a number of errors encountered during internal testing:

  1. Processing of hunks within a patch file was incorrect. We were starting a new hunk every time we saw a --- or +++, but we should have been looking at the number of lines remaining in the current hunk (which started with a @@) to determine if we were at the end of the hunk. In the rare case where the patch is removing a line that starts with --, or adding a line that starts with ++, you'll have a --- or +++ within the hunk which we were treating as a new hunk even though it should not have been. Now, instead of looking for a +++ or --- on every line, we count the number of lines which should be in the hunk and treat those lines as part of the hunk instead of starting a new hunk. As part of implementing this feature, we renamed the _lineschanged array to the more descriptive _oldStart, _oldLength, _newStart, and _newLength variables.

  2. We were not handling hunks which created or removed files correctly. In this case, either the source or target file will appear as /dev/null and we should be able to handle this.

  3. On occasion, srcml was hanging which meant that apply.py also hung. Implement a timeout on the external program calls so that we can detect hangs and error out.

  4. We do not handle binary patches, but we should be able to detect when they appear and raise an appropriate error.

  5. Update the Makefile to automatically install srcml if it's not already installed. The http://gehry.sdml.cs.kent.edu site is unfortunately not available over HTTPS (it's a self-signed certificate and a default Apache testing page) and so for now we are downloading over HTTP. We install it into the env path.

  6. Only ask questions about the possible files to apply the patch to if we are running over a TTY. This avoids the questions being asked if the output of apply.py is being piped to a file or another program.

Unit tests are added for 1, 2, and 4 above.

This patch fixes a number of errors encountered during internal testing:

1. Processing of hunks within a patch file was incorrect.  We were
   starting a new hunk every time we saw a --- or +++, but we should
   have been looking at the number of lines remaining in the current
   hunk (which started with a @@) to determine if we were at the end
   of the hunk.  In the rare case where the patch is removing a line
   that starts with --, or adding a line that starts with ++, you'll
   have a --- or +++ within the hunk which we were treating as a new
   hunk even though it should not have been.  Now, instead of looking
   for a +++ or --- on every line, we count the number of lines which
   should be in the hunk and treat those lines as part of the hunk
   instead of starting a new hunk.  As part of implementing this
   feature, we renamed the _lineschanged array to the more descriptive
   _oldStart, _oldLength, _newStart, and _newLength variables.

2. We were not handling hunks which created or removed files
   correctly.  In this case, either the source or target file will
   appear as /dev/null and we should be able to handle this.

3. On occasion, srcml was hanging which meant that apply.py also hung.
   Implement a timeout on the external program calls so that we can
   detect hangs and error out.

4. We do not handle binary patches, but we should be able to detect
   when they appear and raise an appropriate error.

5. Update the Makefile to automatically install srcml if it's not
   already installed.  The http://gehry.sdml.cs.kent.edu site is
   unfortunately not available over HTTPS (it's a self-signed
   certificate and a default Apache testing page) and so for now we
   are downloading over HTTP.  We install it into the env path.

6. Only ask questions about the possible files to apply the patch to
   if we are running over a TTY.  This avoids the questions being
   asked if the output of apply.py is being piped to a file or another
   program.

Unit tests are added for meido#1, meido#2, and meido#4 above.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant