Commits

Augie Fackler committed e041fda Merge

Merge incoming fix.

  • Participants
  • Parent commits 2669951, f57dfbf

Comments (0)

Files changed (26)

File hggit/__init__.py

     if getattr(discovery, 'findcommonoutgoing', None):
         kwname = 'onlyheads'
     def findoutgoing(orig, local, remote, *args, **kwargs):
-        kw = {}
-        kw.update(kwargs)
-        for val, k in zip(args, ('base', kwname, 'force')):
-            kw[k] = val
         if isinstance(remote, gitrepo.gitrepo):
             # clean up this cruft when we're 1.7-only, remoteheads and
             # the return value change happened between 1.6 and 1.7.
+            kw = {}
+            kw.update(kwargs)
+            for val, k in zip(args, ('base', kwname, 'force')):
+                kw[k] = val
             git = GitHandler(local, local.ui)
             base, heads = git.get_refs(remote.path)
             newkw = {'base': base, kwname: heads}
                 return [x[0] for x in r]
             if kwname == 'onlyheads':
                 del kw['base']
-        return orig(local, remote, **kw)
+            return orig(local, remote, **kw)
+        return orig(local, remote, *args, **kwargs)
     if getattr(discovery, 'findoutgoing', None):
         extensions.wrapfunction(discovery, 'findoutgoing', findoutgoing)
     else:

File hggit/git_handler.py

                 self.lasttopic = topic
 
                 pos, total = map(int, m.group(1, 2))
-                self.ui.progress(topic, pos, total=total)
+                util.progress(self.ui, topic, pos, total=total)
             else:
                 self.flush(msg)
 
     def flush(self, msg=None):
         if self.lasttopic:
-            self.ui.progress(self.lasttopic, None)
+            util.progress(self.ui, self.lasttopic, None)
         self.lasttopic = None
         if msg:
             self.ui.note(msg + '\n')
 
     def import_commits(self, remote_name):
         self.import_git_objects(remote_name)
+        self.update_hg_bookmarks(self.git.get_refs())
         self.save_map()
 
     def fetch(self, remote, heads):
             changed_refs = [ref for ref, sha in new_refs.iteritems()
                             if sha != old_refs.get(ref)]
             new = [bin(self.map_hg_get(new_refs[ref])) for ref in changed_refs]
-            old = dict( (bin(self.map_hg_get(old_refs[r])), 1)
-                       for r in old_refs)
+            old = {}
+            for r in old_refs:
+                old_ref = self.map_hg_get(old_refs[r])
+                if old_ref:
+                    old[bin(old_ref)] = 1
 
             return old, new
         except (HangupException, GitProtocolError), e:
                         raise hgutil.Abort("ambiguous reference %s: %r" % (h, r))
             else:
                 want = [sha for ref, sha in refs.iteritems()
-                        if not ref.endswith('^{}')]
+                        if not ref.endswith('^{}')
+                        and ( ref.startswith('refs/heads/') or ref.startswith('refs/tags/') ) ]
             want = [x for x in want if x not in self.git]
             return want
         f, commit = self.git.object_store.add_pack()
         # Create a local Git branch name for each
         # Mercurial bookmark.
         for key in heads:
-            self.git.refs['refs/heads/' + key] = self.map_git_get(heads[key])
+            git_ref = self.map_git_get(heads[key])
+            if git_ref:
+                self.git.refs['refs/heads/' + key] = self.map_git_get(heads[key])
 
     def export_hg_tags(self):
         for tag, sha in self.repo.tags().iteritems():
                 else:
                     hostpath_seper = '/'
 
+                port = None
                 host, path = hostpath.split(hostpath_seper, 1)
                 if hostpath_seper == '/':
                     transportpath = '/' + path
                 else:
-                    transportpath = path
-                return transport(host, thin_packs=False), transportpath
+                    # port number should be recognized
+                    m = re.match('^(?P<port>\d+)?(?P<path>.*)$', path)
+                    if m.group('port'):
+                        client.port = m.group('port')
+                        port = client.port
+                        transportpath = m.group('path')
+                    else:
+                        transportpath = path
+
+                return transport(host, thin_packs=False, port=port), transportpath
         # if its not git or git+ssh, try a local url..
         return client.SubprocessGitClient(thin_packs=False), uri

File tests/test-conflict-1.out

 pushing to git://localhost/gitrepo
 exporting hg objects to git
 creating and sending data
-Counting objects: 10, done.
-Compressing objects:  25% (1/4)   
-Total 10 (delta 0), reused 0 (delta 0)
 importing git objects into hg
 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
 % expect the same revision ids as above

File tests/test-conflict-2.out

 pushing to git://localhost/gitrepo
 exporting hg objects to git
 creating and sending data
-Counting objects: 10, done.
-Compressing objects:  25% (1/4)   
-Total 10 (delta 0), reused 0 (delta 0)
 importing git objects into hg
 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
 % expect the same revision ids as above

File tests/test-convergedmerge.out

 pushing to git://localhost/gitrepo
 exporting hg objects to git
 creating and sending data
-Counting objects: 11, done.
-Compressing objects:  20% (1/5)   
-Total 11 (delta 0), reused 0 (delta 0)
 importing git objects into hg
 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
 % expect the same revision ids as above

File tests/test-empty-working-tree.out

 
 Initialized empty Git repository in gitrepo2/
 
-Counting objects: 2, done.
-Total 2 (delta 0), reused 0 (delta 0)
 importing git objects into hg
 0 files updated, 0 files merged, 0 files removed, 0 files unresolved
 files: 

File tests/test-encoding.out

 variable i18n.commitencoding to the encoding your project uses.
 Initialized empty Git repository in gitrepo2/
 
-Counting objects: 12, done.
-Compressing objects:  14% (1/7)   
-Total 12 (delta 1), reused 0 (delta 0)
 importing git objects into hg
 4 files updated, 0 files merged, 0 files removed, 0 files unresolved
 @  changeset:   3:8549ee7fe0801b2dafc06047ca6f66d36da709f5

File tests/test-file-removal.out

 beta
 Initialized empty Git repository in gitrepo2/
 
-Counting objects: 14, done.
-Compressing objects:  12% (1/8)   
-Total 14 (delta 1), reused 0 (delta 0)
 importing git objects into hg
 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
 @  changeset:   4:ea41a3f0ed10

File tests/test-git-clone.out

 Initialized empty Git repository in gitrepo/.git/
 
-Counting objects: 6, done.
-Compressing objects:  33% (1/3)   
-Total 6 (delta 0), reused 0 (delta 0)
 importing git objects into hg
 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
 @  changeset:   1:7bcd915dc873

File tests/test-git-submodules.out

  2 files changed, 0 insertions(+), 4 deletions(-)
  delete mode 100644 .gitmodules
  delete mode 160000 subrepo
-Counting objects: 7, done.
-Compressing objects:  20% (1/5)   
-Total 7 (delta 1), reused 0 (delta 0)
 importing git objects into hg
 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
 @  changeset:   2:954cdf1c8c82

File tests/test-git-tags.out

 Initialized empty Git repository in gitrepo/.git/
 
-Counting objects: 7, done.
-Compressing objects:  25% (1/4)   
-Total 7 (delta 0), reused 0 (delta 0)
 importing git objects into hg
 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
 @  changeset:   1:99dcc15b7b07

File tests/test-git-workflow

 echo % get things back to hg
 hg gimport
 hg log --graph --debug | grep -v ': *master'
+echo % gimport should have updated the bookmarks as well
 hg bookmarks

File tests/test-git-workflow.out

    add alpha
 
 
+% gimport should have updated the bookmarks as well
    master                    1:7108ae7bd184

File tests/test-hg-author.out

 Initialized empty Git repository in gitrepo/.git/
 
 Switched to a new branch 'not-master'
-Counting objects: 3, done.
-Total 3 (delta 0), reused 0 (delta 0)
 importing git objects into hg
 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
 0 files updated, 0 files merged, 0 files removed, 0 files unresolved
    date:        Mon Jan 01 00:00:10 2007 +0000
    summary:     add alpha
 
-Counting objects: 9, done.
-Compressing objects:  20% (1/5)   
-Total 9 (delta 0), reused 0 (delta 0)
 importing git objects into hg
 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
 @  changeset:   2:92d33c0dd6e1

File tests/test-hg-branch.out

 Initialized empty Git repository in gitrepo/.git/
 
 Switched to a new branch 'not-master'
-Counting objects: 3, done.
-Total 3 (delta 0), reused 0 (delta 0)
 importing git objects into hg
 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
 0 files updated, 0 files merged, 0 files removed, 0 files unresolved
    date:        Mon Jan 01 00:00:10 2007 +0000
    summary:     add alpha
 
-Counting objects: 6, done.
-Compressing objects:  33% (1/3)   
-Total 6 (delta 0), reused 0 (delta 0)
 importing git objects into hg
 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
 o  changeset:   2:05aed681ccb3

File tests/test-hg-tags.out

 Initialized empty Git repository in gitrepo/.git/
 
 Switched to a new branch 'not-master'
-Counting objects: 3, done.
-Total 3 (delta 0), reused 0 (delta 0)
 importing git objects into hg
 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
 0 files updated, 0 files merged, 0 files removed, 0 files unresolved
 
 % git should have the tag alpha
 alpha
-Counting objects: 6, done.
-Compressing objects:  33% (1/3)   
-Total 6 (delta 0), reused 0 (delta 0)
 importing git objects into hg
 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
 @  changeset:   1:d529e9229f6d

File tests/test-merge.out

  create mode 100644 beta
 Initialized empty Git repository in gitrepo2/
 
-Counting objects: 11, done.
-Compressing objects:  14% (1/7)   
-Total 11 (delta 3), reused 0 (delta 0)
 importing git objects into hg
 3 files updated, 0 files merged, 0 files removed, 0 files unresolved
 % clear the cache to be sure it is regenerated correctly

File tests/test-octopus.out

  create mode 100644 gamma
 Initialized empty Git repository in gitrepo2/
 
-Counting objects: 14, done.
-Compressing objects:  11% (1/9)   
-Total 14 (delta 3), reused 0 (delta 0)
 importing git objects into hg
 4 files updated, 0 files merged, 0 files removed, 0 files unresolved
 @    5:3,4   6523aa9f4775   2007-01-01 00:00 +0000   test

File tests/test-outgoing.out

 Initialized empty Git repository in gitrepo/.git/
 
-Counting objects: 3, done.
-Total 3 (delta 0), reused 0 (delta 0)
 importing git objects into hg
 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
 comparing with git://localhost/gitrepo
 abort: refs/heads/master changed on the server, please pull and merge before pushing
 % let's pull and try again
 pulling from git://localhost/gitrepo
-Counting objects: 3, done.
-Compressing objects:  50% (1/2)   
-Total 3 (delta 0), reused 0 (delta 0)
 importing git objects into hg
 (run 'hg update' to get a working copy)
 comparing with git://localhost/gitrepo

File tests/test-pull-after-strip.out

 
 Switched to a new branch "beta"
 % clone a tag
-Counting objects: 3, done.
-Total 3 (delta 0), reused 0 (delta 0)
 importing git objects into hg
 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
 @  changeset:   0:3442585be8a6
    summary:     add alpha
 
 % clone a branch
-Counting objects: 6, done.
-Compressing objects:  33% (1/3)   
-Total 6 (delta 0), reused 0 (delta 0)
 importing git objects into hg
 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
 @  changeset:   1:7bcd915dc873
 
 0 files updated, 0 files merged, 1 files removed, 0 files unresolved
 pulling from git://localhost/gitrepo
-Counting objects: 6, done.
-Compressing objects:  25% (1/4)   
-Total 6 (delta 0), reused 0 (delta 0)
 importing git objects into hg
 abort: you appear to have run strip - please run hg git-cleanup
 git commit map cleaned

File tests/test-pull.out

 
 Switched to a new branch "beta"
 % clone a tag
-Counting objects: 3, done.
-Total 3 (delta 0), reused 0 (delta 0)
 importing git objects into hg
 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
 @  changeset:   0:3442585be8a6
    summary:     add alpha
 
 % clone a branch
-Counting objects: 6, done.
-Compressing objects:  33% (1/3)   
-Total 6 (delta 0), reused 0 (delta 0)
 importing git objects into hg
 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
 @  changeset:   1:7bcd915dc873

File tests/test-push.out

 Initialized empty Git repository in gitrepo/.git/
 
 Switched to a new branch "not-master"
-Counting objects: 3, done.
-Total 3 (delta 0), reused 0 (delta 0)
 importing git objects into hg
 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
 pushing to git://localhost/gitrepo
 creating and sending data
 abort: refs/heads/master changed on the server, please pull and merge before pushing
 pulling from git://localhost/gitrepo
-Counting objects: 3, done.
-Compressing objects:  50% (1/2)   
-Total 3 (delta 0), reused 0 (delta 0)
 importing git objects into hg
 (run 'hg update' to get a working copy)
 % master and default/master should be diferent

File tests/test-sane-without-bookmarks.out

 Initialized empty Git repository in gitrepo/.git/
 
 creating bookmarks failed, do you have bookmarks enabled?
-Counting objects: 6, done.
-Compressing objects:  33% (1/3)   
-Total 6 (delta 0), reused 0 (delta 0)
 importing git objects into hg
 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
 @  changeset:   1:7bcd915dc873

File tests/test-tree-decomposition.out

 
 Initialized empty Git repository in gitrepo2/
 
-Counting objects: 12, done.
-Compressing objects:  16% (1/6)   
-Total 12 (delta 0), reused 0 (delta 0)
 importing git objects into hg
 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
 adds: d1

File tests/test-url-parsing.py

         except AttributeError:
             self.assertEquals(client.host, 'github.com')
 
+    def test_ssh_github_style_slash_with_port(self):
+        url = "git+ssh://git@github.com:10022/webjam/webjam.git"
+        client, path = self.handler.get_transport_and_path(url)
+        self.assertEquals(path, '/webjam/webjam.git')
+        self.assertEquals(client.host, 'git@github.com')
+        self.assertEquals(client.port, '10022')
+
+    def test_gitdaemon_style_with_port(self):
+        url = "git://github.com:19418/webjam/webjam.git"
+        client, path = self.handler.get_transport_and_path(url)
+        self.assertEquals(path, '/webjam/webjam.git')
+        try:
+            self.assertEquals(client._host, 'github.com')
+        except AttributeError:
+            self.assertEquals(client.host, 'github.com')
+        self.assertEquals(client._port, '19418')
 
 if __name__ == '__main__':
     tc = TestUrlParsing()
     for test in ['test_ssh_github_style_slash',
                  'test_ssh_github_style_colon',
                  'test_ssh_heroku_style',
-                 'test_gitdaemon_style']:
+                 'test_gitdaemon_style',
+                 'test_ssh_github_style_slash_with_port',
+                 'test_gitdaemon_style_with_port']:
         tc.setUp()
         getattr(tc, test)()
         tc.tearDown()

File tests/test-url-parsing.py.out

 /webjam/webjam.git
 % expect 'github.com'
 github.com
+% expect '/webjam/webjam.git'
+/webjam/webjam.git
+% expect 'git@github.com'
+git@github.com
+% expect '10022'
+10022
+% expect '/webjam/webjam.git'
+/webjam/webjam.git
+% expect 'github.com'
+github.com
+% expect '19418'
+19418