[BUG] Changesets that create empty files produce bogus patches
John A Meinel
john at arbash-meinel.com
Thu Jul 28 15:15:54 BST 2005
Aaron Bentley wrote:
> I've been working on an exact-patching function for bzr. It seems very
> easy. One problem I've found is that bogus patches are used by
> note_patch. This happens when an empty file is added to the tree:
>
> *** added file sub/sub/emptyfile.txt //
> file-id:emptyfile.txt-20050727055518-be8239eb8f9d79ca //
> text-id:emptyfile.txt-20050727055518-9810517032907c49
> *** added file sub/sub/nonempty.txt ...
Well, if you do:
touch a
diff -u /dev/null a
You get no output.
>
> No patch. A patch to add an empty file might look like:
> --- /dev/null
> +++ mod/sub/sub/emptyfile.txt
> @@ -0,0 +1,1 @@
> +
> \ No newline at end of file
I don't know that the above is a genuine statement. I would say that we
could easily just realize that an "add" with no content means we should
create an empty file.
I think the above patch looks pretty ugly, and doesn't really make it
clear that it is an empty file. (It could have whitespace)
John
=:->
>
> But we don't get anything like that in note_patch; we get an empty
> string. I think we should only feed valid patches to note_patch.
>
> Here is a patch that will let you reproduce the problem:
>
> --- read_changeset.py
> +++ read_changeset.py
> @@ -690,6 +690,7 @@
>
> def note_patch(self, new_path, patch):
> """There is a patch for a given filename."""
> + assert len(patch) > 0, "invalid patch for %s" % new_path
> self.patches[new_path] = patch
>
> def note_deletion(self, old_path):
>
> Aaron
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 253 bytes
Desc: OpenPGP digital signature
Url : https://lists.ubuntu.com/archives/bazaar/attachments/20050728/f530eaa0/attachment.pgp
More information about the bazaar
mailing list