diff mercurial/subrepo.py @ 12994:845c602b8635

subrepo: allow git subrepos to push and merge (master branch only) gitsubrepo based on patch from David Soria Parra: http://bitbucket.org/segv/davids-poor-git-subrepo-attempt/
author Eric Eisner <ede@mit.edu>
date Sun, 14 Nov 2010 18:22:33 -0500
parents a91334380699
children d90fc91c8377
line wrap: on
line diff
--- a/mercurial/subrepo.py	Sun Nov 14 18:20:13 2010 -0500
+++ b/mercurial/subrepo.py	Sun Nov 14 18:22:33 2010 -0500
@@ -678,6 +678,25 @@
         # circumstances
         return self._gitstate()
 
+    def merge(self, state):
+        source, revision, kind = state
+        self._fetch(source, revision)
+        base = self._gitcommand(['merge-base', revision,
+                                 self._state[1]]).strip()
+        if base == revision:
+            self.get(state) # fast forward merge
+        elif base != self._state[1]:
+            self._gitcommand(['merge', '--no-commit', revision])
+
+    def push(self, force):
+        cmd = ['push']
+        if force:
+            cmd.append('--force')
+        # as subrepos have no notion of "where to push to" we
+        # assume origin master. This is git's default
+        self._gitcommand(cmd + ['origin', 'master', '-q'])
+        return True
+
 types = {
     'hg': hgsubrepo,
     'svn': svnsubrepo,