1

I am using Beyond Compare 3.0 and using the XML tidy and XML tidied with sorted attributes plugins. Its great and while I would like it to show me the "tidied" XML, Once I resolve me merge, I would like to save it back with the original formatting (not the tidied format). Is there anyway of doing this?

For example, if I have these two XML snippets -

File1 : <test attrib="1" batrib="2" catrib="3"\>
File2 : <test batrib="4" catrib="5" attrib="5"\>

I would like to visually see them tidied up and attributes sorted, so I can make my changes/resoluutions. For example, If I resolve to change the value of attrib to 5 and keep the rest, When I save the file, I want to see this ...

Final : <test attrib="5" batrib="2" catrib="3">

Not : <test 
        attrib="5" 
        batrib="2" 
        catrib="3">

Beyond compare seems to save the file in the second format (tidied) up.

Any Idea how I can go about fixing this?

Regards ...

rahul
  • 184,426
  • 49
  • 232
  • 263
Chaitanya
  • 5,203
  • 8
  • 36
  • 61

2 Answers2

1

The best way I can think of is to use Visual Studio's format document feature to re-un-tidy the file after you've merged.

Foozinator
  • 400
  • 3
  • 11
  • I have posted this to the beyondcompare forums http://www.scootersoftware.com/vbulletin/showthread.php?t=4903 they suggest a different answer, that I haven't had time to test out yet. Your suggestion is definitely much easier and simpler though. – Chaitanya Jul 16 '09 at 06:25
0

I think Pretty Diff does what you are attempting to accomplish. It minifies input to remove comments and then beautifies input prior to running the diff algorithm so as to remove all differences attributed to white space and comments.

http://prettydiff.com/

austincheney
  • 1,097
  • 7
  • 8
  • yes, but the issue wasn't about doing the prettified diff. The issue was UN-prettifying it after I was done with the diff/merge. If I resolve one conflict in a file, I don't want to save the prettyfied version. If someone else from my team looked at the file history later on, they would see the entire file changed/prettified. I only wanted to see it prettified, modify it prettified, but save it back in the original formatting (white space intact, unprettified) – Chaitanya Dec 11 '11 at 00:09
  • I don't think that can be done, because how would an application know what your original code looked like after you make changes based upon an algorithmic diff? The only exception is if there is some sort of schema in place specific for defining and validating white space rules and your instance document strictly follows the guidance of that schema and you have algorithms in place to automatically restore documents to a validated state. If you do not such in place already then how would any program know what restore point to follow after consideration for a merge condition? – austincheney Dec 11 '11 at 03:52
  • I guess when the program does the prettification, it can keep track of all the transforms performed, perhaps at the character level. So character 19 in original file at position x has moved to position y in prettified. Remember prettification is for display only in my scenario. When I make changes to the prettified version, it keeps track of what characters changed (inserts, deletes or substitutions). When I click save, it can undo the transformations. So character at position y in prettified version goes back to x. Subsitutions chars are easy to manage. Inserts and deletes can also be managed – Chaitanya Dec 12 '11 at 07:39
  • The problem with that logic that makes it a bit more complicated is that your injected changes change the length of the new output relative to the length of the old output. While it is simple to separately maintain cumulative length of the changes it is a bit more complicated to maintain that per relative character position while simultaneously maintaining relative character position as changes are injected. – austincheney Dec 12 '11 at 19:11
  • Agreed. I didn't say it was trivial. But even doing a normal diff or prettification is pretty complex. But nevertheless it's algorithmicmically possible. In fact, most of the stuff done by programming tools, whether it is profiling, debugging, diffing, merging, code coverage calculations etc. are pretty complex. Not something I would tackle myself, but luckily can buy off the shelf. – Chaitanya Dec 13 '11 at 03:29