Show More
@@ -665,6 +665,10 b' class gitsubrepo(object):' | |||
|
665 | 665 | out, code = self._gitdir(['cat-file', '-e', revision]) |
|
666 | 666 | return code == 0 |
|
667 | 667 | |
|
668 | def _gitisancestor(self, r1, r2): | |
|
669 | base = self._gitcommand(['merge-base', r1, r2]).strip() | |
|
670 | return base == r1 | |
|
671 | ||
|
668 | 672 | def _gitbranchmap(self): |
|
669 | 673 | 'returns the current branch and a map from git revision to branch[es]' |
|
670 | 674 | bm = {} |
@@ -767,17 +771,31 b' class gitsubrepo(object):' | |||
|
767 | 771 | self._gitcommand(['merge', '--no-commit', revision]) |
|
768 | 772 | |
|
769 | 773 | def push(self, force): |
|
774 | # if a branch in origin contains the revision, nothing to do | |
|
775 | current, bm = self._gitbranchmap() | |
|
776 | for revision, branches in bm.iteritems(): | |
|
777 | for b in branches: | |
|
778 | if b.startswith('remotes/origin'): | |
|
779 | if self._gitisancestor(self._state[1], revision): | |
|
780 | return True | |
|
781 | # otherwise, try to push the currently checked out branch | |
|
770 | 782 | cmd = ['push'] |
|
771 | 783 | if force: |
|
772 | 784 | cmd.append('--force') |
|
773 | # push the currently checked out branch | |
|
774 | current, bm = self._gitbranchmap() | |
|
775 | 785 | if current: |
|
786 | # determine if the current branch is even useful | |
|
787 | if not self._gitisancestor(self._state[1], current): | |
|
788 | self._ui.warn(_('unrelated git branch checked out ' | |
|
789 | 'in subrepo %s\n') % self._relpath) | |
|
790 | return False | |
|
791 | self._ui.status(_('pushing branch %s of subrepo %s\n') % | |
|
792 | (current, self._relpath)) | |
|
776 | 793 | self._gitcommand(cmd + ['origin', current, '-q']) |
|
777 | 794 | return True |
|
778 | 795 | else: |
|
779 | 796 | self._ui.warn(_('no branch checked out in subrepo %s\n' |
|
780 |
'not |
|
|
797 | 'cannot push revision %s') % | |
|
798 | (self._relpath, self._state[1])) | |
|
781 | 799 | return False |
|
782 | 800 | |
|
783 | 801 | def remove(self): |
@@ -134,6 +134,7 b' user b push changes' | |||
|
134 | 134 | |
|
135 | 135 | $ hg push |
|
136 | 136 | pushing to $TESTTMP/t |
|
137 | pushing branch testing of subrepo s | |
|
137 | 138 | searching for changes |
|
138 | 139 | adding changesets |
|
139 | 140 | adding manifests |
@@ -170,12 +171,44 b' user a pulls, merges, commits' | |||
|
170 | 171 | revision f47b465e1bce645dbf37232a00574aa1546ca8d3 |
|
171 | 172 | $ hg push |
|
172 | 173 | pushing to $TESTTMP/t |
|
174 | pushing branch testing of subrepo s | |
|
173 | 175 | searching for changes |
|
174 | 176 | adding changesets |
|
175 | 177 | adding manifests |
|
176 | 178 | adding file changes |
|
177 | 179 | added 2 changesets with 2 changes to 1 files |
|
178 | 180 | |
|
181 | make upstream git changes | |
|
182 | ||
|
183 | $ cd .. | |
|
184 | $ git clone -q gitroot gitclone | |
|
185 | $ cd gitclone | |
|
186 | $ echo ff >> f | |
|
187 | $ git commit -q -a -m ff | |
|
188 | $ echo fff >> f | |
|
189 | $ git commit -q -a -m fff | |
|
190 | $ git push -q origin testing | |
|
191 | ||
|
192 | make and push changes to hg without updating the subrepo | |
|
193 | ||
|
194 | $ cd ../t | |
|
195 | $ hg clone . ../td | |
|
196 | updating to branch default | |
|
197 | cloning subrepo s | |
|
198 | checking out detached HEAD in subrepo s | |
|
199 | check out a git branch if you intend to make changes | |
|
200 | 3 files updated, 0 files merged, 0 files removed, 0 files unresolved | |
|
201 | $ cd ../td | |
|
202 | $ echo aa >> a | |
|
203 | $ hg commit -m aa | |
|
204 | $ hg push | |
|
205 | pushing to $TESTTMP/t | |
|
206 | searching for changes | |
|
207 | adding changesets | |
|
208 | adding manifests | |
|
209 | adding file changes | |
|
210 | added 1 changesets with 1 changes to 1 files | |
|
211 | ||
|
179 | 212 | update to a revision without the subrepo, keeping the local git repository |
|
180 | 213 | |
|
181 | 214 | $ cd ../t |
General Comments 0
You need to be logged in to leave comments.
Login now