dusty-phillips / gitifyhg

Tools for using git as a client to mercurial repositories
GNU General Public License v3.0
62 stars 17 forks source link

Handle closed branch heads better #74

Closed fingolfin closed 11 years ago

fingolfin commented 11 years ago

Right now, I get a warning like this upon each fetch on a repository I work on:

WARNING: "Branch 'foobar' has more than one head, consider merging"

It is true that the branch foobar has two heads: One is the actual in-use head, the other is a "closed" head, marked by one of our devs as unused. It would be nice if gitifiyhg would not print that warning for closed heads. At least by default.

To reproduce this, consider this example:

$ hg init closed-branch
$ cd closed-branch/
$ echo a > a
$ hg add a
$ hg commit -m a a
$ echo b1 > a
$ hg commit -m "b1"
$ hg update 0
1 files updated, 0 files merged, 0 files removed, 0 files unresolved
$ echo b2 > a
$ hg commit -m "b2"
created new head
$ hg heads
changeset:   2:3a5101580047
tag:         tip
parent:      0:766a9d7f1207
user:        Max Horn <max@quendi.de>
date:        Tue Apr 16 17:50:20 2013 +0200
summary:     b2

changeset:   1:76899fac3b04
user:        Max Horn <max@quendi.de>
date:        Tue Apr 16 17:50:06 2013 +0200
summary:     b1
$ hg commit --close-branch -m "Close branch head"
$ hg update default
1 files updated, 0 files merged, 0 files removed, 0 files unresolved
$ hg heads
changeset:   1:76899fac3b04
user:        Max Horn <max@quendi.de>
date:        Tue Apr 16 17:50:06 2013 +0200
summary:     b1
$ git clone gitifyhg::. clone
Cloning into 'clone'...
WARNING: "Branch 'default' has more than one head, consider merging"
WARNING: "Branch 'default' has more than one head, consider merging"
$
dusty-phillips commented 11 years ago

I'm not sure I addressed this as "better" but after #80, closed branches only show up if the user explicitly sets the GITIFYHG_ALLOW_CLOSED_BRANCHES environment variable. See the commit on #80 for more information.

I feel a better configuration setup than environment variables is justified here, but this is the route I want to go going forward.