Mercurial > hg > hg-git
view tests/test-hg-branch.t @ 599:792955be68dd
Only export modified Git trees
Previously, we emitted every Git tree when updating between Mercurial
changesets. With this patch, we now only emit Git trees that changed. A
side-effect of the implementation is that we now only update in-memory
Git trees objects that changed. Before, we always touched Git trees,
invalidating them in the process and causing Dulwich to recalculate
their SHA-1. Profiling revealed this to be expensive and removing the
extra calculation shows a nice performance win.
Another optimization is to not sort the order that changed paths are
processed in. Previously, we sorted by length, longest to shortest.
Profiling revealed that the sorts took a non-trivial amount of time.
While sorted execution resulted in likely idempotent behavior, it
shouldn't be strictly required.
On the author's machine, conversion of the Mercurial repository itself
decreased from ~493s to ~333s. Even more impressive is conversion of
Firefox's main repository (which is considerably larger). Converting the
first 200 revisions of that repository decreased from ~152s to ~42s.
author | Gregory Szorc <gregory.szorc@gmail.com> |
---|---|
date | Sun, 14 Apr 2013 11:11:41 -0700 |
parents | a6b7ad535244 |
children | f1bac7f37a05 |
line wrap: on
line source
Load commonly used test logic $ . "$TESTDIR/testutil" $ git init gitrepo Initialized empty Git repository in $TESTTMP/gitrepo/.git/ $ cd gitrepo $ echo alpha > alpha $ git add alpha $ fn_git_commit -m "add alpha" $ git checkout -b not-master Switched to a new branch 'not-master' $ cd .. $ hg clone gitrepo hgrepo | grep -v '^updating' importing git objects into hg 1 files updated, 0 files merged, 0 files removed, 0 files unresolved $ cd hgrepo $ hg co master 0 files updated, 0 files merged, 0 files removed, 0 files unresolved $ hg mv alpha beta $ fn_hg_commit -m 'rename alpha to beta' $ hg push pushing to $TESTTMP/gitrepo searching for changes adding objects added 1 commits with 1 trees and 0 blobs updating reference refs/heads/master $ hg branch gamma | grep -v 'permanent and global' marked working directory as branch gamma $ fn_hg_commit -m 'started branch gamma' $ hg push pushing to $TESTTMP/gitrepo searching for changes adding objects added 1 commits with 1 trees and 0 blobs updating reference refs/heads/master $ hg log --graph | egrep -v ': *(not-master|master)' @ changeset: 2:05aed681ccb3 | branch: gamma | tag: default/master | tag: tip | user: test | date: Mon Jan 01 00:00:12 2007 +0000 | summary: started branch gamma | o changeset: 1:a31e374801c9 | user: test | date: Mon Jan 01 00:00:11 2007 +0000 | summary: rename alpha to beta | o changeset: 0:3442585be8a6 tag: default/not-master user: test <test@example.org> date: Mon Jan 01 00:00:10 2007 +0000 summary: add alpha $ cd .. $ hg clone gitrepo hgrepo2 | grep -v '^updating' importing git objects into hg 1 files updated, 0 files merged, 0 files removed, 0 files unresolved $ hg -R hgrepo2 log --graph | egrep -v ': *(not-master|master)' o changeset: 2:05aed681ccb3 | branch: gamma | tag: default/master | tag: tip | user: test | date: Mon Jan 01 00:00:12 2007 +0000 | summary: started branch gamma | @ changeset: 1:a31e374801c9 | user: test | date: Mon Jan 01 00:00:11 2007 +0000 | summary: rename alpha to beta | o changeset: 0:3442585be8a6 tag: default/not-master user: test <test@example.org> date: Mon Jan 01 00:00:10 2007 +0000 summary: add alpha