minecraft-data icon indicating copy to clipboard operation
minecraft-data copied to clipboard

Display a diff of two versions of the protocol

Open rom1504 opened this issue 9 years ago • 13 comments

Would be interesting.

rom1504 avatar May 21 '16 02:05 rom1504

16:23 <hansihe> i would think the optimal way to maintain the protocol files would be to start at some base version, then have each version be represented as a diff from the last 16:23 <hansihe> then generate the full files 16:24 <hansihe> keep in mind i have little knowledge on how you maintain/add new versions, but if it was done like that, changes to things like naming in one protocol version would (mostly) automatically be propagated to the others

This might be a good idea.

rom1504 avatar May 31 '16 15:05 rom1504

A diff could simply contain the packet that changed. Things that would need to be done:

  • [ ] script to generate the diff between 2 protocol.json
  • [ ] script to generate the full file from a base and a diff

rom1504 avatar May 31 '16 15:05 rom1504

Lol. This was the way I originally wanted to handle the protocol data, and after a long argument with... erm, either myself or you " ? I opted to go down the "full protocol.json route".

A pro of diffs is that if there's a bug in 1.5 that snowballs to 1.6, 1.7, etc..., fixing it in 1.5 will fix all affected versions. The con is obviously that if 1.6 didn't have that change, well now you broke the later versions.

Another con is that each protocol.json becomes dependant on the previous ones to make sense.

roblabla avatar May 31 '16 16:05 roblabla

Yeah we argued about that a long time ago. My problem with it (as Gjum just said on gitter) was mostly that then users have to generate the protocol.json themselves. But if we have the diff + the full file then it's convenient enough. (we change the diff manually, and generate the full file automatically)

rom1504 avatar May 31 '16 16:05 rom1504

And it makes much more sense now that we support snapshots and many small versions, there are little diff between those. And that the name-id mapping is just in one packet.

rom1504 avatar May 31 '16 16:05 rom1504

just a quick idea, we can have a git hook that autogenerates the full file from the diffs pretty easily. so we don't forget. Also will want to have the build status make sure the generated file matches the in-tree file

roblabla avatar May 31 '16 17:05 roblabla

Here is a proposal for a json diff format:

old means "types to remove", new means "types to add"

We could use something like this to display a more useful diff between types. (Without having to define a diff format for each type)

rom1504 avatar Jun 05 '16 22:06 rom1504

Why the need to specify the oldType ? Is it purely for diff readability ?

roblabla avatar Jun 05 '16 22:06 roblabla

Because without it we don't know what packets to remove. Also it makes the diff reversable (which might be useful I guess ?)

rom1504 avatar Jun 05 '16 22:06 rom1504

Although if we don't care about reversability, we could add a "removedTypes" with just a list of names. (and remove oldTypes)

rom1504 avatar Jun 05 '16 22:06 rom1504

I think the full jsons are better for projects that will only be using the information of one protocol. I don't want to have to patch a base json with a diff if I can use a complete one instead.

I do think displaying the diffs is a good idea. It might be the easiest way to store them, but their use cases are fewer.

phase avatar Jun 15 '16 00:06 phase

Even if we put json diff in the repo, the full files will still be available ;)

rom1504 avatar Jun 15 '16 08:06 rom1504

@phase the idea is to make maintenance (AKA editing the files) easier, along with making the differences easier to see. The full file will still be available, but will be auto-generated when pushing a modifications by going from the base file and applying the patch files.

roblabla avatar Jun 15 '16 17:06 roblabla