Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

original:

if __name__ == "__main__":
    myparams = {"server":"mpilgrim", \
                    "database":"master", \
                    "uid":"sa", \
                    "pwd":"secret" \
                    }

cutting of bzr diff:

 if __name__ == "__main__":
     myparams = {"server":"mpilgrim", \
@@ -15,4 +22,6 @@
                     "pwd":"secret" \
                     }

What means the '@@ -15,4 +22,6 @@' part of bzr diff and why does it overwrite two lines?

"database":"master", \
"uid":"sa", \
share|improve this question

1 Answer 1

up vote 3 down vote accepted

You have provided excerpts from a context diff, which shows both lines that are the same in both files and lines that are changed. However, the excerpts you have selected don't actually show any changed lines. (Those would be preceded with - or + characters, depending on whether they're being removed or added.)

@@ -15,4 +22,6 @@ means that 4 lines starting with line 15 in the old file are are changed (or not changed, but shown as context), and correspond to 6 lines starting with line 22 in the new file. (The simplest and overwhelmingly most common way for this to occur is that the number of lines added in the new file exceeds the number of lines removed in the new file by 7, such that what started on line 15 in the old file starts on line 22 in the new file, prior to application of the changes about to be specified.)

Since this is a context diff, it provides some lines for context that don't specify changes. This is useful to allow people editing the files (developers/maintainers, when it's source code, as in this case) to know what's going on by skimming the diff. But it has the other useful purpose of making it possible, in many cases, to apply a diff created against one version of a file against another version of the same file, provided that it doesn't change the exact same lines that were already changed (i.e., that were changed after the diff was created but before it is being applied).

The following lines are presumably present, as context, in the diff, because there was a change shortly before them (so they are context provided after a change):

if __name__ == "__main__":
    myparams = {"server":"mpilgrim", \

Whereas these lines are presumably present, as context, in the diff, because there is going to be a change shortly after them (so they are context provided before a change):

                     "pwd":"secret" \
                     }

These lines are presumably not sufficiently close to any change specified in the diff to be included as context:

                    "database":"master", \
                    "uid":"sa", \

That's why they seem as though they are missing in the diff. They're not really missing, because a diff is not supposed to show you the entire file. The take home message of all this is that their absence is not because the diff is specifying that they be removed. It is certainly not specifying that--if it were, it would have to include them (with - signs before them to indicate their removal).

(I say presumably above not because there is any strong likelihood that this isn't what is going on, but because while the diff utility will create diffs with specified numbers of before and after context lines, you could, if you wanted, manually create or modify a diff so that it had more or fewer context lines in some places than in others, and it would still be a valid diff, provided that, where necessary, the numbers in @@ lines where changed to match.)

For more information about diff (the diff, patch, diff3, and sdiff utilities, and also the diff/patch format), see the GNU diff documentation. In particular, you may be interested in the section on the part about the unified format.

share|improve this answer
    
Thanks a lot. I'm new to bzr and tried all kind of stuff. The bzr help page is really huge and contains much useful informations but not that piece of information that allows the user to completely understand the output. –  Paradiesstaub Nov 13 '11 at 21:30

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.