diff rhodecode/lib/vcs/backends/git/repository.py @ 2209:19a6c23af14b beta

Implemented pull command for remote repos for git - added mimic ui objects into GitRepos to better handle hooks logic
author Marcin Kuzminski <marcin@python-works.com>
date Thu, 26 Apr 2012 23:55:33 +0200
parents d7a4c7e3528e
children 7b458dd6f40d
line wrap: on
line diff
--- a/rhodecode/lib/vcs/backends/git/repository.py	Thu Apr 26 21:22:13 2012 +0200
+++ b/rhodecode/lib/vcs/backends/git/repository.py	Thu Apr 26 23:55:33 2012 +0200
@@ -47,6 +47,15 @@
 
         self.path = abspath(repo_path)
         self._repo = self._get_repo(create, src_url, update_after_clone, bare)
+        #temporary set that to now at later we will move it to constructor
+        baseui = None
+        if baseui is None:
+            from mercurial.ui import ui
+            baseui = ui()
+        # patch the instance of GitRepo with an "FAKE" ui object to add 
+        # compatibility layer with Mercurial
+        setattr(self._repo, 'ui', baseui)
+
         try:
             self.head = self._repo.head()
         except KeyError:
@@ -471,6 +480,17 @@
         # If error occurs run_git_command raises RepositoryError already
         self.run_git_command(cmd)
 
+    def pull(self, url):
+        """
+        Tries to pull changes from external location.
+        """
+        url = self._get_url(url)
+        cmd = ['pull']
+        cmd.append("--ff-only")
+        cmd = ' '.join(cmd)
+        # If error occurs run_git_command raises RepositoryError already
+        self.run_git_command(cmd)
+
     @LazyProperty
     def workdir(self):
         """