You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@subversion.apache.org by Daniel Näslund <da...@longitudo.com> on 2010/02/04 20:11:00 UTC

[PATCH] Test context within fuzzy hunk for 'svn patch'

Hi!

[[[
* subversion/tests/cmdline/patch_tests.py
  (patch_with_fuzz): Add context in the middle of one of the fuzzy
    hunks.

Patch by: Daniel N�slund <daniel{_AT_}longitudo.com>
]]]

Re: [PATCH] v2 Test context within fuzzy hunk for 'svn patch'

Posted by Julian Foad <ju...@wandisco.com>.
Daniel Näslund wrote:
> Stefan Sperling wrote:
[...]
> >  * subversion/tests/cmdline/patch_tests.py
> >    (patch_with_fuzz): For determining fuzz we have an algorithm that
> >     should only check for trailing and leading context. Make this test
> >     verify that this property of the algorithm holds by adding context
> >     in the middle of one of the hunks. Also fix an indentation error.
> > 
> > What do you think?
> 
> Looks good.

It's *beautiful*.

:-)

>  This sounds silly but I often feel a bit of rush when I'm
> finished with a patch. It's like if I was thinking to myself: 'If I don't
> get it in immediately, the bug may disappear by itself'. I'm trying
> to slow down and give more thought to things. The most valueable lesson
> so far from contributing to subversion is the importance of beeing
> concious of all the choises I make when programming. In the end, writing
> a log message should be pretty easy if I really understand what I've
> been doing. :-)

I recognize those thoughts.

- Julian


Re: [PATCH] v2 Test context within fuzzy hunk for 'svn patch'

Posted by Daniel Näslund <da...@longitudo.com>.
On Fri, Feb 05, 2010 at 08:41:04PM +0100, Stefan Sperling wrote:
> On Fri, Feb 05, 2010 at 08:03:46PM +0100, Daniel Näslund wrote:
> > New log message which is ridiciously long for such a small change.
> 
> No, your new log message is much better! It's not ridiculous.
> 
> The basic algorithm for writing good log messages is:
> 
> 1) Write the log message.
> 2) Think about *why* you are making the change.
> 3) Look for the answer to this question in the log message
>    you've just written. If it is not there, go to step 1.
> 4) You're done.

A good algorithm. Perhaps it should be added to 'HACKING'. Although
there is *a lot* about writing log messages there. I admit to not having
studied it as detailed as I should have. Read it last summer and thought
I had grasped all of it but at a second look, that was not the case.
> 
> The rest is partly intuition and partly practice.
> 
> You're almost right saying that really good log messages are short.
> But it's not shortness that makes a log message good, but conciseness
> (i.e. high information density).
> 
> > Feedback on it is welcome:
> > 
> > [[[
> > For determining fuzz we have an algorithm that should only check for
> > trailing and leading context. Add a small regression test to existing
> > testcase. At the same time fix small typo.
> 
> So this is better than what was there before (there was nothing before :)
> 
> If you make the second sentence refer to things mentioned in the first
> one, it's even clearer what the regression test is for.
> You can also easily say what kind of typo you've fixed:
> 
>  For determining fuzz we have an algorithm that should only check for
>  trailing and leading context. Make an existing existing test case verify
>  that this property of the algorithm holds. At the same time fix an
>  indentation error.
> 
> And you can even merge the above text into this part of your
> log message:
> 
> > 
> > * subversion/tests/cmdline/patch_tests.py
> >   (patch_with_fuzz): Add context in the middle of one of the fuzzy
> >     hunks.
> 
> because that function is the only scope of all your changes.
> Which also shortens the log message a bit because now you can use the
> pronoun 'this' to refer to the existing test case.
> I'm also doing s/At the same time/Also/ because it provides the same
> information but is shorter:
> 
>  * subversion/tests/cmdline/patch_tests.py
>    (patch_with_fuzz): For determining fuzz we have an algorithm that
>     should only check for trailing and leading context. Make this test
>     verify that this property of the algorithm holds by adding context
>     in the middle of one of the hunks. Also fix an indentation error.
> 
> What do you think?

Looks good. This sounds silly but I often feel a bit of rush when I'm
finished with a patch. It's like if I was thinking to myself: 'If I don't
get it in immediately, the bug may disappear by itself'. I'm trying
to slow down and give more thought to things. The most valueable lesson
so far from contributing to subversion is the importance of beeing
concious of all the choises I make when programming. In the end, writing
a log message should be pretty easy if I really understand what I've
been doing. :-)

Daniel

Re: [PATCH] v2 Test context within fuzzy hunk for 'svn patch'

Posted by Daniel Näslund <da...@longitudo.com>.
On Fri, Feb 05, 2010 at 08:41:04PM +0100, Stefan Sperling wrote:
> On Fri, Feb 05, 2010 at 08:03:46PM +0100, Daniel Näslund wrote:
> > New log message which is ridiciously long for such a small change.
> 
> No, your new log message is much better! It's not ridiculous.
> 
> The basic algorithm for writing good log messages is:
> 
> 1) Write the log message.
> 2) Think about *why* you are making the change.
> 3) Look for the answer to this question in the log message
>    you've just written. If it is not there, go to step 1.
> 4) You're done.

A good algorithm. Perhaps it should be added to 'HACKING'. Although
there is *a lot* about writing log messages there. I admit to not having
studied it as detailed as I should have. Read it last summer and thought
I had grasped all of it but at a second look, that was not the case.
> 
> The rest is partly intuition and partly practice.
> 
> You're almost right saying that really good log messages are short.
> But it's not shortness that makes a log message good, but conciseness
> (i.e. high information density).
> 
> > Feedback on it is welcome:
> > 
> > [[[
> > For determining fuzz we have an algorithm that should only check for
> > trailing and leading context. Add a small regression test to existing
> > testcase. At the same time fix small typo.
> 
> So this is better than what was there before (there was nothing before :)
> 
> If you make the second sentence refer to things mentioned in the first
> one, it's even clearer what the regression test is for.
> You can also easily say what kind of typo you've fixed:
> 
>  For determining fuzz we have an algorithm that should only check for
>  trailing and leading context. Make an existing existing test case verify
>  that this property of the algorithm holds. At the same time fix an
>  indentation error.
> 
> And you can even merge the above text into this part of your
> log message:
> 
> > 
> > * subversion/tests/cmdline/patch_tests.py
> >   (patch_with_fuzz): Add context in the middle of one of the fuzzy
> >     hunks.
> 
> because that function is the only scope of all your changes.
> Which also shortens the log message a bit because now you can use the
> pronoun 'this' to refer to the existing test case.
> I'm also doing s/At the same time/Also/ because it provides the same
> information but is shorter:
> 
>  * subversion/tests/cmdline/patch_tests.py
>    (patch_with_fuzz): For determining fuzz we have an algorithm that
>     should only check for trailing and leading context. Make this test
>     verify that this property of the algorithm holds by adding context
>     in the middle of one of the hunks. Also fix an indentation error.
> 
> What do you think?

Looks good. This sounds silly but I often feel a bit of rush when I'm
finished with a patch. It's like if I was thinking to myself: 'If I don't
get it in immediately, the bug may disappear by itself'. I'm trying
to slow down and give more thought to things. The most valueable lesson
so far from contributing to subversion is the importance of beeing
concious of all the choises I make when programming. In the end, writing
a log message should be pretty easy if I really understand what I've
been doing. :-)

Daniel

Re: [PATCH] v2 Test context within fuzzy hunk for 'svn patch'

Posted by Stefan Sperling <st...@elego.de>.
On Fri, Feb 05, 2010 at 08:03:46PM +0100, Daniel Näslund wrote:
> New log message which is ridiciously long for such a small change.

No, your new log message is much better! It's not ridiculous.

The basic algorithm for writing good log messages is:

1) Write the log message.
2) Think about *why* you are making the change.
3) Look for the answer to this question in the log message
   you've just written. If it is not there, go to step 1.
4) You're done.

The rest is partly intuition and partly practice.

You're almost right saying that really good log messages are short.
But it's not shortness that makes a log message good, but conciseness
(i.e. high information density).

> Feedback on it is welcome:
> 
> [[[
> For determining fuzz we have an algorithm that should only check for
> trailing and leading context. Add a small regression test to existing
> testcase. At the same time fix small typo.

So this is better than what was there before (there was nothing before :)

If you make the second sentence refer to things mentioned in the first
one, it's even clearer what the regression test is for.
You can also easily say what kind of typo you've fixed:

 For determining fuzz we have an algorithm that should only check for
 trailing and leading context. Make an existing existing test case verify
 that this property of the algorithm holds. At the same time fix an
 indentation error.

And you can even merge the above text into this part of your
log message:

> 
> * subversion/tests/cmdline/patch_tests.py
>   (patch_with_fuzz): Add context in the middle of one of the fuzzy
>     hunks.

because that function is the only scope of all your changes.
Which also shortens the log message a bit because now you can use the
pronoun 'this' to refer to the existing test case.
I'm also doing s/At the same time/Also/ because it provides the same
information but is shorter:

 * subversion/tests/cmdline/patch_tests.py
   (patch_with_fuzz): For determining fuzz we have an algorithm that
    should only check for trailing and leading context. Make this test
    verify that this property of the algorithm holds by adding context
    in the middle of one of the hunks. Also fix an indentation error.

What do you think?

Stefan

Re: [PATCH] v2 Test context within fuzzy hunk for 'svn patch'

Posted by Stefan Sperling <st...@elego.de>.
On Fri, Feb 05, 2010 at 08:03:46PM +0100, Daniel Näslund wrote:
> New log message which is ridiciously long for such a small change.

No, your new log message is much better! It's not ridiculous.

The basic algorithm for writing good log messages is:

1) Write the log message.
2) Think about *why* you are making the change.
3) Look for the answer to this question in the log message
   you've just written. If it is not there, go to step 1.
4) You're done.

The rest is partly intuition and partly practice.

You're almost right saying that really good log messages are short.
But it's not shortness that makes a log message good, but conciseness
(i.e. high information density).

> Feedback on it is welcome:
> 
> [[[
> For determining fuzz we have an algorithm that should only check for
> trailing and leading context. Add a small regression test to existing
> testcase. At the same time fix small typo.

So this is better than what was there before (there was nothing before :)

If you make the second sentence refer to things mentioned in the first
one, it's even clearer what the regression test is for.
You can also easily say what kind of typo you've fixed:

 For determining fuzz we have an algorithm that should only check for
 trailing and leading context. Make an existing existing test case verify
 that this property of the algorithm holds. At the same time fix an
 indentation error.

And you can even merge the above text into this part of your
log message:

> 
> * subversion/tests/cmdline/patch_tests.py
>   (patch_with_fuzz): Add context in the middle of one of the fuzzy
>     hunks.

because that function is the only scope of all your changes.
Which also shortens the log message a bit because now you can use the
pronoun 'this' to refer to the existing test case.
I'm also doing s/At the same time/Also/ because it provides the same
information but is shorter:

 * subversion/tests/cmdline/patch_tests.py
   (patch_with_fuzz): For determining fuzz we have an algorithm that
    should only check for trailing and leading context. Make this test
    verify that this property of the algorithm holds by adding context
    in the middle of one of the hunks. Also fix an indentation error.

What do you think?

Stefan

Re: [PATCH] v2 Test context within fuzzy hunk for 'svn patch'

Posted by Daniel Näslund <da...@longitudo.com>.
On Thu, Feb 04, 2010 at 10:53:26PM +0100, Stefan Sperling wrote:
> On Thu, Feb 04, 2010 at 08:11:00PM +0100, Daniel N�slund wrote:

> Can you explain why?

We have changed a part of the hunk parsing logic to only check for fuzz
at start and end of a hunk. It should not take intermediate context into
account.  

> +    "@@ -7,7 +8,9 @@\n",
>      " and 50,000,000 individual email addresses from all over the world.\n",
>      " \n",
>      " Your email address drew and have won the sum of  750,000 Euros\n",
>      "+Another new line\n",
>      " ( Seven Hundred and Fifty Thousand Euros) in cash credited to\n",
> +    "+A third new line\n",
>      " file with\n",
>      "     REFERENCE NUMBER: ESP/WIN/008/05/10/MA;\n",
> +    "    WINNING NUMBER : 14-17-24-34-37-45-16\n",

> Is the indentation of the above line off on purpose?

The extra space was a typo when I created the test. Fixed it at the same
time. 

New log message which is ridiciously long for such a small change.
Feedback on it is welcome:

[[[
For determining fuzz we have an algorithm that should only check for
trailing and leading context. Add a small regression test to existing
testcase. At the same time fix small typo.

* subversion/tests/cmdline/patch_tests.py
  (patch_with_fuzz): Add context in the middle of one of the fuzzy
    hunks.

Patch by: Daniel N�slund <daniel{_AT_}longitudo.com>
]]]

Re: [PATCH] v2 Test context within fuzzy hunk for 'svn patch'

Posted by Daniel Näslund <da...@longitudo.com>.
On Thu, Feb 04, 2010 at 10:53:26PM +0100, Stefan Sperling wrote:
> On Thu, Feb 04, 2010 at 08:11:00PM +0100, Daniel Näslund wrote:

> Can you explain why?

We have changed a part of the hunk parsing logic to only check for fuzz
at start and end of a hunk. It should not take intermediate context into
account.  

> +    "@@ -7,7 +8,9 @@\n",
>      " and 50,000,000 individual email addresses from all over the world.\n",
>      " \n",
>      " Your email address drew and have won the sum of  750,000 Euros\n",
>      "+Another new line\n",
>      " ( Seven Hundred and Fifty Thousand Euros) in cash credited to\n",
> +    "+A third new line\n",
>      " file with\n",
>      "     REFERENCE NUMBER: ESP/WIN/008/05/10/MA;\n",
> +    "    WINNING NUMBER : 14-17-24-34-37-45-16\n",

> Is the indentation of the above line off on purpose?

The extra space was a typo when I created the test. Fixed it at the same
time. 

New log message which is ridiciously long for such a small change.
Feedback on it is welcome:

[[[
For determining fuzz we have an algorithm that should only check for
trailing and leading context. Add a small regression test to existing
testcase. At the same time fix small typo.

* subversion/tests/cmdline/patch_tests.py
  (patch_with_fuzz): Add context in the middle of one of the fuzzy
    hunks.

Patch by: Daniel Näslund <daniel{_AT_}longitudo.com>
]]]

Re: [PATCH] Test context within fuzzy hunk for 'svn patch'

Posted by Stefan Sperling <st...@elego.de>.
On Thu, Feb 04, 2010 at 08:11:00PM +0100, Daniel Näslund wrote:
> Hi!
> 
> [[[
> * subversion/tests/cmdline/patch_tests.py
>   (patch_with_fuzz): Add context in the middle of one of the fuzzy
>     hunks.
> 
> Patch by: Daniel Näslund <daniel{_AT_}longitudo.com>
> ]]]

Can you explain why?

> Index: subversion/tests/cmdline/patch_tests.py
> ===================================================================
> --- subversion/tests/cmdline/patch_tests.py	(revision 906596)
> +++ subversion/tests/cmdline/patch_tests.py	(arbetskopia)
> @@ -1105,19 +1105,21 @@
>      " Balloting. This is a Millennium Scientific Electronic Computer Draw\n",
>      " in which email addresses were used. All participants were selected\n",
>      " through a computer ballot system drawn from over 100,000 company\n",
> -    "@@ -7,6 +8,7 @@\n",
> +    "@@ -7,7 +8,9 @@\n",
>      " and 50,000,000 individual email addresses from all over the world.\n",
>      " \n",
>      " Your email address drew and have won the sum of  750,000 Euros\n",
>      "+Another new line\n",
>      " ( Seven Hundred and Fifty Thousand Euros) in cash credited to\n",
> +    "+A third new line\n",
>      " file with\n",
>      "     REFERENCE NUMBER: ESP/WIN/008/05/10/MA;\n",
> +    "    WINNING NUMBER : 14-17-24-34-37-45-16\n",

Is the indentation of the above line off on purpose?

Thanks,
Stefan

>      "@@ -19,6 +20,7 @@\n",
>      " To claim your winning prize, you are to contact the appointed\n",
>      " agent below as soon as possible for the immediate release of your\n",
>      " winnings with the below details.\n",
> -    "+A third new line\n",
> +    "+A fourth new line\n",
>      " \n",
>      " Again, we wish to congratulate you over your email success in our\n"
>      " computer Balloting. [No trailing newline here]"
> @@ -1138,6 +1140,7 @@
>      "Your email address drew and have won the sum of  750,000 Euros\n",
>      "Another new line\n",
>      "( Seven Hundred and Fifty Thousand Euros) in cash credited to\n",
> +    "A third new line\n",
>      "file with\n",
>      "    REFERENCE NUMBER: ESP/WIN/008/05/10/MA;\n",
>      "    WINNING NUMBER : 14-17-24-34-37-45-16\n",
> @@ -1150,7 +1153,7 @@
>      "To claim your winning prize, you are to contact the appointed\n",
>      "agent below as soon as possible for the immediate release of your\n",
>      "winnings with the below details.\n",
> -    "A third new line\n",
> +    "A fourth new line\n",
>      "\n",
>      "Line replaced for fuzz = 2\n",
>      "Line replaced for fuzz = 2\n",
> @@ -1159,7 +1162,7 @@
>    expected_output = [
>      'U         %s\n' % os.path.join(wc_dir, 'A', 'mu'),
>      '>         applied hunk @@ -1,6 +1,7 @@ with fuzz 1\n',
> -    '>         applied hunk @@ -7,6 +8,7 @@ with fuzz 2\n',
> +    '>         applied hunk @@ -7,7 +8,9 @@ with fuzz 2\n',
>      '>         applied hunk @@ -19,6 +20,7 @@ with offset 1 and fuzz 2\n',
>    ]
>    expected_disk = svntest.main.greek_state.copy()


-- 
printf("Eh???/n");

Re: [PATCH] Test context within fuzzy hunk for 'svn patch'

Posted by Stefan Sperling <st...@elego.de>.
On Thu, Feb 04, 2010 at 08:11:00PM +0100, Daniel Näslund wrote:
> Hi!
> 
> [[[
> * subversion/tests/cmdline/patch_tests.py
>   (patch_with_fuzz): Add context in the middle of one of the fuzzy
>     hunks.
> 
> Patch by: Daniel Näslund <daniel{_AT_}longitudo.com>
> ]]]

Can you explain why?

> Index: subversion/tests/cmdline/patch_tests.py
> ===================================================================
> --- subversion/tests/cmdline/patch_tests.py	(revision 906596)
> +++ subversion/tests/cmdline/patch_tests.py	(arbetskopia)
> @@ -1105,19 +1105,21 @@
>      " Balloting. This is a Millennium Scientific Electronic Computer Draw\n",
>      " in which email addresses were used. All participants were selected\n",
>      " through a computer ballot system drawn from over 100,000 company\n",
> -    "@@ -7,6 +8,7 @@\n",
> +    "@@ -7,7 +8,9 @@\n",
>      " and 50,000,000 individual email addresses from all over the world.\n",
>      " \n",
>      " Your email address drew and have won the sum of  750,000 Euros\n",
>      "+Another new line\n",
>      " ( Seven Hundred and Fifty Thousand Euros) in cash credited to\n",
> +    "+A third new line\n",
>      " file with\n",
>      "     REFERENCE NUMBER: ESP/WIN/008/05/10/MA;\n",
> +    "    WINNING NUMBER : 14-17-24-34-37-45-16\n",

Is the indentation of the above line off on purpose?

Thanks,
Stefan

>      "@@ -19,6 +20,7 @@\n",
>      " To claim your winning prize, you are to contact the appointed\n",
>      " agent below as soon as possible for the immediate release of your\n",
>      " winnings with the below details.\n",
> -    "+A third new line\n",
> +    "+A fourth new line\n",
>      " \n",
>      " Again, we wish to congratulate you over your email success in our\n"
>      " computer Balloting. [No trailing newline here]"
> @@ -1138,6 +1140,7 @@
>      "Your email address drew and have won the sum of  750,000 Euros\n",
>      "Another new line\n",
>      "( Seven Hundred and Fifty Thousand Euros) in cash credited to\n",
> +    "A third new line\n",
>      "file with\n",
>      "    REFERENCE NUMBER: ESP/WIN/008/05/10/MA;\n",
>      "    WINNING NUMBER : 14-17-24-34-37-45-16\n",
> @@ -1150,7 +1153,7 @@
>      "To claim your winning prize, you are to contact the appointed\n",
>      "agent below as soon as possible for the immediate release of your\n",
>      "winnings with the below details.\n",
> -    "A third new line\n",
> +    "A fourth new line\n",
>      "\n",
>      "Line replaced for fuzz = 2\n",
>      "Line replaced for fuzz = 2\n",
> @@ -1159,7 +1162,7 @@
>    expected_output = [
>      'U         %s\n' % os.path.join(wc_dir, 'A', 'mu'),
>      '>         applied hunk @@ -1,6 +1,7 @@ with fuzz 1\n',
> -    '>         applied hunk @@ -7,6 +8,7 @@ with fuzz 2\n',
> +    '>         applied hunk @@ -7,7 +8,9 @@ with fuzz 2\n',
>      '>         applied hunk @@ -19,6 +20,7 @@ with offset 1 and fuzz 2\n',
>    ]
>    expected_disk = svntest.main.greek_state.copy()


-- 
printf("Eh???/n");