changeset 705:373f854ff58f

git_handler.fetch: only import commits reachable from requested heads Previously we'd attempt to import every single reachable commit in the Git object store. The test adds another branch to the Git repo and doesn't import it until much later. Previously we'd import it when we ran `hg -R hgrepo pull -r beta`. Now we won't.
author Siddharth Agarwal <sid0@fb.com>
date Tue, 04 Mar 2014 16:23:11 -0800
parents 4cddcb768cf4
children 4e0e9e25b03b
files hggit/git_handler.py tests/test-pull.t
diffstat 2 files changed, 30 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- a/hggit/git_handler.py
+++ b/hggit/git_handler.py
@@ -206,7 +206,8 @@
         oldheads = self.repo.changelog.heads()
         imported = 0
         if refs:
-            imported = self.import_git_objects(remote_name, refs)
+            filteredrefs = self.filter_refs(refs, heads)
+            imported = self.import_git_objects(remote_name, filteredrefs)
             self.import_tags(refs)
             self.update_hg_bookmarks(refs)
             if remote_name:
--- a/tests/test-pull.t
+++ b/tests/test-pull.t
@@ -12,6 +12,10 @@
   $ echo beta > beta
   $ git add beta
   $ fn_git_commit -m 'add beta'
+  $ git checkout -qb delta master
+  $ echo delta > delta
+  $ git add delta
+  $ fn_git_commit -m 'add delta'
   $ cd ..
 
 clone a tag (ideally we'd want to pull it, but that seems broken for now)
@@ -57,6 +61,7 @@
   
 add another commit and tag to the git repo
   $ cd gitrepo
+  $ git checkout -q beta
   $ git tag t_beta
   $ git checkout -q master
   $ echo gamma > gamma
@@ -70,15 +75,23 @@
   importing git objects into hg
   (run 'hg heads' to see heads, 'hg merge' to merge)
   $ hg -R hgrepo log --graph
-  o  changeset:   2:37c124f2d0a0
+  o  changeset:   3:56cabe48c4b0
   |  bookmark:    master
   |  tag:         default/master
   |  tag:         tip
   |  parent:      0:3442585be8a6
   |  user:        test <test@example.org>
-  |  date:        Mon Jan 01 00:00:12 2007 +0000
+  |  date:        Mon Jan 01 00:00:13 2007 +0000
   |  summary:     add gamma
   |
+  | o  changeset:   2:4d41070bf840
+  |/   bookmark:    delta
+  |    tag:         default/delta
+  |    parent:      0:3442585be8a6
+  |    user:        test <test@example.org>
+  |    date:        Mon Jan 01 00:00:12 2007 +0000
+  |    summary:     add delta
+  |
   | o  changeset:   1:7bcd915dc873
   |/   bookmark:    beta
   |    tag:         default/beta
@@ -108,22 +121,30 @@
   importing git objects into hg
   (run 'hg update' to get a working copy)
   $ hg -R hgrepo log --graph
-  o    changeset:   3:b8668fddf56c
+  o    changeset:   4:892d20308ddf
   |\   bookmark:    master
   | |  tag:         default/master
   | |  tag:         tip
-  | |  parent:      2:37c124f2d0a0
+  | |  parent:      3:56cabe48c4b0
   | |  parent:      1:7bcd915dc873
   | |  user:        test <test@example.org>
-  | |  date:        Mon Jan 01 00:00:12 2007 +0000
+  | |  date:        Mon Jan 01 00:00:13 2007 +0000
   | |  summary:     Merge branch 'beta'
   | |
-  | o  changeset:   2:37c124f2d0a0
+  | o  changeset:   3:56cabe48c4b0
   | |  parent:      0:3442585be8a6
   | |  user:        test <test@example.org>
-  | |  date:        Mon Jan 01 00:00:12 2007 +0000
+  | |  date:        Mon Jan 01 00:00:13 2007 +0000
   | |  summary:     add gamma
   | |
+  | | o  changeset:   2:4d41070bf840
+  | |/   bookmark:    delta
+  | |    tag:         default/delta
+  | |    parent:      0:3442585be8a6
+  | |    user:        test <test@example.org>
+  | |    date:        Mon Jan 01 00:00:12 2007 +0000
+  | |    summary:     add delta
+  | |
   o |  changeset:   1:7bcd915dc873
   |/   bookmark:    beta
   |    tag:         default/beta