Commits

Brendan Cully committed 60d181f

Make pull results more like hg pulls.

Returns the number of changed heads (refs).
Uses the same "no changes found" message.

  • Participants
  • Parent commits de0b266

Comments (0)

Files changed (2)

hggit/git_handler.py

         refs = self.fetch_pack(remote, heads)
         remote_name = self.remote_name(remote)
 
+        oldrefs = self.git.get_refs()
         if refs:
             self.import_git_objects(remote_name, refs)
             self.import_tags(refs)
                               lambda : None)()
                 if bms:
                     bookmarks.setcurrent(self.repo, bms[0])
-        else:
-            self.ui.status(_("nothing new on the server\n"))
+
+        def remoteref(ref):
+            rn = remote_name or 'default'
+            if ref.startswith('refs/tags/'):
+                return ref
+            return 'refs/remotes/' + rn + ref[10:]
+
+        modheads = set([refs[k] for k in refs if k != 'HEAD'
+                        and refs[k] != oldrefs.get(remoteref(k))])
+
+        if not modheads:
+            self.ui.status(_("no changes found\n"))
 
         self.save_map()
 
+        return len(modheads)
+
     def export_commits(self):
         try:
             self.export_git_objects()
         def pull(self, remote, heads=None, force=False):
             if isinstance(remote, gitrepo):
                 git = GitHandler(self, self.ui)
-                git.fetch(remote.path, heads)
+                return git.fetch(remote.path, heads)
             else: #pragma: no cover
                 return super(hgrepo, self).pull(remote, heads, force)