fu: Close-up of Fu, bringing a scoop of water to her mouth (Default)
fu ([staff profile] fu) wrote2011-09-07 03:10 pm

Some useful settings when generating patches

Mercurial has a setting which tries to figure out what function you're in, and adds that to the patch output. It's really helpful when reviewing, so I recommend turning it on. For example, compare this diff:


--- a/bin/upgrading/s2layers/core2.s2 Tue Aug 30 22:12:52 2011 -0500
+++ b/bin/upgrading/s2layers/core2.s2 Wed Aug 31 04:45:59 2011 +0000
@@ -331,6 +331,8 @@
var readonly Tag[] tags "Array of tags applied to this entry.";

var Image userpic "The userpic selected to relate to this entry.";
+ var Image userpic_orig "FIXME";
+ var int itemid "Server stored ID number for this entry";

var readonly string{} metadata "Post metadata. Keys: 'music', 'mood', 'location', 'groups', 'xpost'. Comment metadata. Key: 'poster_ip'";

@@ -378,7 +380,6 @@
var bool new_day "Is this entry on a different day to the previous one?";
var bool end_day "Is this the last entry of a day?";

- var int itemid "Server stored ID number for this entry";

function print_metatypes(bool icon, bool info) "Print the metatype information for this entry";



With this one:

--- a/bin/upgrading/s2layers/core2.s2
+++ b/bin/upgrading/s2layers/core2.s2
@@ -331,6 +331,8 @@ class EntryLite
var readonly Tag[] tags "Array of tags applied to this entry.";

var Image userpic "The userpic selected to relate to this entry.";
+ var Image userpic_orig "FIXME";
+ var int itemid "Server stored ID number for this entry";

var readonly string{} metadata "Post metadata. Keys: 'music', 'mood', 'location', 'groups', 'xpost'. Comment metadata. Key: 'poster_ip'";

@@ -378,7 +380,6 @@ class Entry extends EntryLite
var bool new_day "Is this entry on a different day to the previous one?";
var bool end_day "Is this the last entry of a day?";

- var int itemid "Server stored ID number for this entry";

function print_metatypes(bool icon, bool info) "Print the metatype information for this entry";




Voila, instant context :) To turn it on, edit your .hgrc file:

nano ~/.hgrc

And then paste this section in it:

[diff]
showfunc=true
git=true


showfunc=true makes Mercurial try to parse out the function the lines are changing in. git=true makes Mercurial behave git-like in some aspects, the most important one being that it'll save changes to binary files (such as images) within the generated patch, so that someone applying the patch will have your image placed into the proper path. That is, without your needing to upload the image separately along with instructions for where the image should go.
sophie: A cartoon-like representation of a girl standing on a hill, with brown hair, blue eyes, a flowery top, and blue skirt. ☀ (Default)

[personal profile] sophie 2011-09-07 11:56 am (UTC)(link)
I didn't know any of this!

If wanted, I can put this into the global hgrc on the Dreamhack server. :)
ninetydegrees: Drawing: a girl's pale face, with a yellow and green stripe over her right eye (Default)

[personal profile] ninetydegrees 2011-09-07 12:12 pm (UTC)(link)
Isn't showfunc=true on by default? Because I think I have this in my patches.
Also git=true messed things up for me (I can't remember how exactly but I think it messed my queue when I was adding/removing files) It was very probably because I didn't do things the right way, though.
sophie: A cartoon-like representation of a girl standing on a hill, with brown hair, blue eyes, a flowery top, and blue skirt. ☀ (Default)

[personal profile] sophie 2011-09-07 12:42 pm (UTC)(link)
Hmm, if it messes things up, then maybe it won't be a good idea to add it as the Dreamhack default.

As for showfunc, you're actually right - it *is* on by default on the old Dreamhack server, but not on the new Dreamhack server, which is where I generated my latest patch that Fu reviewed, which most likely prompted this post. I'll make sure showfunc is on by default on the new server too :)
floatboth: (Default)

[personal profile] floatboth 2011-09-07 03:22 pm (UTC)(link)
wow! wonder if git can do this…