Show More
@@ -761,16 +761,32 b' class gitsubrepo(abstractsubrepo):' | |||
|
761 | 761 | self._gitcommand(['reset', '--hard', 'HEAD']) |
|
762 | 762 | return |
|
763 | 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 | 770 | return |
|
765 | 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 | 783 | def rawcheckout(): |
|
768 | 784 | # no branch to checkout, check it out with no branch |
|
769 | 785 | self._ui.warn(_('checking out detached HEAD in subrepo %s\n') % |
|
770 | 786 | self._relpath) |
|
771 | 787 | self._ui.warn(_('check out a git branch if you intend ' |
|
772 | 788 | 'to make changes\n')) |
|
773 |
|
|
|
789 | checkout(['-q', revision]) | |
|
774 | 790 | |
|
775 | 791 | if revision not in rev2branch: |
|
776 | 792 | rawcheckout() |
@@ -780,12 +796,12 b' class gitsubrepo(abstractsubrepo):' | |||
|
780 | 796 | for b in branches: |
|
781 | 797 | if b == 'refs/heads/master': |
|
782 | 798 | # master trumps all other branches |
|
783 |
|
|
|
799 | checkout(['refs/heads/master']) | |
|
784 | 800 | return |
|
785 | 801 | if not firstlocalbranch and not b.startswith('refs/remotes/'): |
|
786 | 802 | firstlocalbranch = b |
|
787 | 803 | if firstlocalbranch: |
|
788 |
|
|
|
804 | checkout([firstlocalbranch]) | |
|
789 | 805 | return |
|
790 | 806 | |
|
791 | 807 | tracking = self._gittracking(branch2rev.keys()) |
@@ -800,7 +816,7 b' class gitsubrepo(abstractsubrepo):' | |||
|
800 | 816 | if remote not in tracking: |
|
801 | 817 | # create a new local tracking branch |
|
802 | 818 | local = remote.split('/', 2)[2] |
|
803 |
|
|
|
819 | checkout(['-b', local, remote]) | |
|
804 | 820 | elif self._gitisancestor(branch2rev[tracking[remote]], remote): |
|
805 | 821 | # When updating to a tracked remote branch, |
|
806 | 822 | # if the local tracking branch is downstream of it, |
@@ -809,7 +825,7 b' class gitsubrepo(abstractsubrepo):' | |||
|
809 | 825 | # Since we are only looking at branching at update, we need to |
|
810 | 826 | # detect this situation and perform this action lazily. |
|
811 | 827 | if tracking[remote] != self._gitcurrentbranch(): |
|
812 |
|
|
|
828 | checkout([tracking[remote]]) | |
|
813 | 829 | self._gitcommand(['merge', '--ff', remote]) |
|
814 | 830 | else: |
|
815 | 831 | # a real merge would be required, just checkout the revision |
@@ -304,3 +304,21 b' nested archive' | |||
|
304 | 304 | $ ls ../narchive/inner/s | grep -v pax_global_header |
|
305 | 305 | f |
|
306 | 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