Show More
@@ -761,16 +761,32 class gitsubrepo(abstractsubrepo): | |||||
761 | self._gitcommand(['reset', '--hard', 'HEAD']) |
|
761 | self._gitcommand(['reset', '--hard', 'HEAD']) | |
762 | return |
|
762 | return | |
763 | elif self._gitstate() == revision: |
|
763 | elif self._gitstate() == revision: | |
|
764 | if overwrite: | |||
|
765 | # first reset the index to unmark new files for commit, because | |||
|
766 | # reset --hard will otherwise throw away files added for commit, | |||
|
767 | # not just unmark them. | |||
|
768 | self._gitcommand(['reset', 'HEAD']) | |||
|
769 | self._gitcommand(['reset', '--hard', 'HEAD']) | |||
764 | return |
|
770 | return | |
765 | branch2rev, rev2branch = self._gitbranchmap() |
|
771 | branch2rev, rev2branch = self._gitbranchmap() | |
766 |
|
772 | |||
|
773 | def checkout(args): | |||
|
774 | cmd = ['checkout'] | |||
|
775 | if overwrite: | |||
|
776 | # first reset the index to unmark new files for commit, because | |||
|
777 | # the -f option will otherwise throw away files added for | |||
|
778 | # commit, not just unmark them. | |||
|
779 | self._gitcommand(['reset', 'HEAD']) | |||
|
780 | cmd.append('-f') | |||
|
781 | self._gitcommand(cmd + args) | |||
|
782 | ||||
767 | def rawcheckout(): |
|
783 | def rawcheckout(): | |
768 | # no branch to checkout, check it out with no branch |
|
784 | # no branch to checkout, check it out with no branch | |
769 | self._ui.warn(_('checking out detached HEAD in subrepo %s\n') % |
|
785 | self._ui.warn(_('checking out detached HEAD in subrepo %s\n') % | |
770 | self._relpath) |
|
786 | self._relpath) | |
771 | self._ui.warn(_('check out a git branch if you intend ' |
|
787 | self._ui.warn(_('check out a git branch if you intend ' | |
772 | 'to make changes\n')) |
|
788 | 'to make changes\n')) | |
773 |
|
|
789 | checkout(['-q', revision]) | |
774 |
|
790 | |||
775 | if revision not in rev2branch: |
|
791 | if revision not in rev2branch: | |
776 | rawcheckout() |
|
792 | rawcheckout() | |
@@ -780,12 +796,12 class gitsubrepo(abstractsubrepo): | |||||
780 | for b in branches: |
|
796 | for b in branches: | |
781 | if b == 'refs/heads/master': |
|
797 | if b == 'refs/heads/master': | |
782 | # master trumps all other branches |
|
798 | # master trumps all other branches | |
783 |
|
|
799 | checkout(['refs/heads/master']) | |
784 | return |
|
800 | return | |
785 | if not firstlocalbranch and not b.startswith('refs/remotes/'): |
|
801 | if not firstlocalbranch and not b.startswith('refs/remotes/'): | |
786 | firstlocalbranch = b |
|
802 | firstlocalbranch = b | |
787 | if firstlocalbranch: |
|
803 | if firstlocalbranch: | |
788 |
|
|
804 | checkout([firstlocalbranch]) | |
789 | return |
|
805 | return | |
790 |
|
806 | |||
791 | tracking = self._gittracking(branch2rev.keys()) |
|
807 | tracking = self._gittracking(branch2rev.keys()) | |
@@ -800,7 +816,7 class gitsubrepo(abstractsubrepo): | |||||
800 | if remote not in tracking: |
|
816 | if remote not in tracking: | |
801 | # create a new local tracking branch |
|
817 | # create a new local tracking branch | |
802 | local = remote.split('/', 2)[2] |
|
818 | local = remote.split('/', 2)[2] | |
803 |
|
|
819 | checkout(['-b', local, remote]) | |
804 | elif self._gitisancestor(branch2rev[tracking[remote]], remote): |
|
820 | elif self._gitisancestor(branch2rev[tracking[remote]], remote): | |
805 | # When updating to a tracked remote branch, |
|
821 | # When updating to a tracked remote branch, | |
806 | # if the local tracking branch is downstream of it, |
|
822 | # if the local tracking branch is downstream of it, | |
@@ -809,7 +825,7 class gitsubrepo(abstractsubrepo): | |||||
809 | # Since we are only looking at branching at update, we need to |
|
825 | # Since we are only looking at branching at update, we need to | |
810 | # detect this situation and perform this action lazily. |
|
826 | # detect this situation and perform this action lazily. | |
811 | if tracking[remote] != self._gitcurrentbranch(): |
|
827 | if tracking[remote] != self._gitcurrentbranch(): | |
812 |
|
|
828 | checkout([tracking[remote]]) | |
813 | self._gitcommand(['merge', '--ff', remote]) |
|
829 | self._gitcommand(['merge', '--ff', remote]) | |
814 | else: |
|
830 | else: | |
815 | # a real merge would be required, just checkout the revision |
|
831 | # a real merge would be required, just checkout the revision |
@@ -304,3 +304,21 nested archive | |||||
304 | $ ls ../narchive/inner/s | grep -v pax_global_header |
|
304 | $ ls ../narchive/inner/s | grep -v pax_global_header | |
305 | f |
|
305 | f | |
306 | g |
|
306 | g | |
|
307 | ||||
|
308 | Check hg update --clean | |||
|
309 | $ cd $TESTTMP/t | |||
|
310 | $ echo > s/g | |||
|
311 | $ cd s | |||
|
312 | $ echo c1 > f1 | |||
|
313 | $ echo c1 > f2 | |||
|
314 | $ git add f1 | |||
|
315 | $ git status --short | |||
|
316 | A f1 | |||
|
317 | M g | |||
|
318 | ?? f2 | |||
|
319 | $ cd .. | |||
|
320 | $ hg update -C > /dev/null 2>/dev/null | |||
|
321 | $ cd s | |||
|
322 | $ git status --short | |||
|
323 | ?? f1 | |||
|
324 | ?? f2 |
General Comments 0
You need to be logged in to leave comments.
Login now