Skip to content

Commit

Permalink
Do not clone closed branches by default.
Browse files Browse the repository at this point in the history
Fixes #80.

This is a controversial fix in some ways; an earlier commit explicitly turned on cloning of closed branches. However, I feel that the default should be to not clone closed branches. There are a few reasons for this.

The main one is that a closed branch in mercurial is generally considered the equivalent of a deleted branch in git. Therefore, we do not want the deleted branch in git.

A second one is that cloning closed branches can take a great deal of time that is, for the above reason, completely wasted.

A third one is that we have a few problems with branch naming (eg #78, #75, #62) that are caused by conflicting branched names. This fix does not solve those issues, but when the conflicting branches are closed branches, it does prevent them from causing a clone to fail outright.
  • Loading branch information
= committed Apr 30, 2013
1 parent 8ef7dd5 commit ecdb14e
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 1 deletion.
5 changes: 4 additions & 1 deletion gitifyhg/gitifyhg.py
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,10 @@ def do_list(self, parser):

# update the named branch references
for branch in self.repo.branchmap():
heads = self.repo.branchheads(branch, closed=True)
# FIXME: Probably a git config instead of an env var would make
# people happier here.
clone_closed = os.environ.get("GITIFYHG_ALLOW_CLOSED_BRANCHES") != None
heads = self.repo.branchheads(branch, closed=clone_closed)
if heads:
self.branches[branch] = heads

Expand Down
25 changes: 25 additions & 0 deletions test/test_clone.t
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,9 @@ test_expect_success 'clone basic tag' '

test_expect_success 'clone close branch' '
test_when_finished "rm -rf hg_repo git_clone" &&
test_when_finished "unset GITIFYHG_ALLOW_CLOSED_BRANCHES" &&
export GITIFYHG_ALLOW_CLOSED_BRANCHES=on &&
make_hg_repo &&
hg branch feature &&
make_hg_commit b b &&
Expand All @@ -119,4 +121,27 @@ test_expect_success 'clone close branch' '
cd ..
'

test_expect_success 'no implicit clone close branch' '
test_when_finished "rm -rf hg_repo git_clone" &&
echo $GITIFYHG_ALLOW_CLOSED_BRANCHES &&
make_hg_repo &&
hg branch feature &&
make_hg_commit b b &&
hg update default &&
make_hg_commit c c &&
hg update feature &&
echo d >> b &&
hg commit --close-branch -m "d" &&
clone_repo &&
git branch -r &&
test "`git branch -r`" = " origin/HEAD -> origin/master
origin/master" &&
assert_git_messages "c${NL}a" &&
cd ..
'


test_done

0 comments on commit ecdb14e

Please sign in to comment.