In order to get rid of a habit (or in this case, the impulse to reach for food when you're feeling down), you need to attach a negative association with the action that is strong enough to overshadow the pleasure you gain from partaking in the habit. Or eradicate the beliefs and the psychological causes behind the behaviour in the first place. Unfortunately, with over-eating, the situation is a bit complex.
Like any habit, over-eating has long-term and short-term benefits. The short-term benefits are obvious. Beyond the oral-fixation and the satisfaction of cravings, the thing with food is that it provides an instant dose of pleasure. In a world where we're taught that rewards come after hours, days, weeks or months of back-breaking work (sometimes with no reward in sight!), food allows for a unique solution in that is offers instant gratification. And unlike drugs or other such decadent habits, it is a normal, everyday function of a living organism that just happens to be pleasant.
Unfortunately, the entertainment and the exploding diet industry has threatened to encroach on that. Suddenly, eating must be a mindful, restricted activity that aligns it with the principles of delayed gratification in order to obtain yet another lofty, society-established goal. Every where you go, you're assaulted by all these complicated diet theories; all the lists of things you should eat and lists of things you shouldn't eat; which seemingly harmless food combinations are actually dangerous, and which surprising "super foods" can make you healthier. Not to mention, the visual of the entire song and dance it takes to get to the gym and sweat it all off. It all so complex and jumbled, that suddenly, a normal, balanced meal at dinner time which otherwise might have been a pleasurable experience, carries all the negativity and the pressure heaped on by society.
So, of course, the people who find comfort in food must now look for ways to step out of that negative sphere of influence, and they usually do it by upping their dose and thus, rebelling against those expectations in order to get their relief. Which is why one chocolate bar or a handful of chips won't do it; that's being 'health conscious.' That's still being in line with the draconian expectations of society and that doesn't satisfy that empty pit you feel. After all, chances are, if you're depressed, on one level or another you already don't feel like you're able to keep up with society no matter how hard you try... so the last thing you want to do is comfort yourself in accordance to those expectations!
That's of course, just one theory of why depression offers itself up so readily to self-indulgent behaviors, but it's (forgive the horrible pun) food for thought.
The other theory is that you actually want to gain mass in order to put on psychological and biological armor. Biologically, the bigger you are, the better you are at protecting yourself. Psychologically, the more weight you gain, the more you can excuse yourself as being a work in progress. By focusing on your fail-and-fail-again efforts to lose weight, you're distracting yourself from addressing other, more intimidating psychological issues. These might be the long-term benefits of over-eating and again, like the theory above it, are actually related to issues of frustration and "protecting" yourself from society. At the core, the problem is feelings of powerlessness.
Of course, I don't claim to know that this is the case for everyone. There are dozens upon dozens of psychological theories that might be used to explain over-eating. Still, it is my opinion that most people might fall in between the two theories discussed above... and if they ring true for anyone here, it might be beneficial to start by looking closely at the beliefs that lay foundation to the issue. Frustration? Lack of self-confidence? Fear of success/failure? Authority issues? They may read like pop-psychology buzz words, but they're actually a very good place to start narrowing things down for yourself.