Show More
@@ -703,6 +703,9 class gitsubrepo(abstractsubrepo): | |||||
703 |
|
703 | |||
704 | return retdata, p.returncode |
|
704 | return retdata, p.returncode | |
705 |
|
705 | |||
|
706 | def _gitmissing(self): | |||
|
707 | return not os.path.exists(os.path.join(self._abspath, '.git')) | |||
|
708 | ||||
706 | def _gitstate(self): |
|
709 | def _gitstate(self): | |
707 | return self._gitcommand(['rev-parse', 'HEAD']) |
|
710 | return self._gitcommand(['rev-parse', 'HEAD']) | |
708 |
|
711 | |||
@@ -759,7 +762,7 class gitsubrepo(abstractsubrepo): | |||||
759 | return _abssource(self) |
|
762 | return _abssource(self) | |
760 |
|
763 | |||
761 | def _fetch(self, source, revision): |
|
764 | def _fetch(self, source, revision): | |
762 | if not os.path.exists(os.path.join(self._abspath, '.git')): |
|
765 | if self._gitmissing(): | |
763 | self._ui.status(_('cloning subrepo %s\n') % self._relpath) |
|
766 | self._ui.status(_('cloning subrepo %s\n') % self._relpath) | |
764 | self._gitnodir(['clone', self._abssource(source), self._abspath]) |
|
767 | self._gitnodir(['clone', self._abssource(source), self._abspath]) | |
765 | if self._githavelocally(revision): |
|
768 | if self._githavelocally(revision): | |
@@ -772,6 +775,8 class gitsubrepo(abstractsubrepo): | |||||
772 | (revision, self._relpath)) |
|
775 | (revision, self._relpath)) | |
773 |
|
776 | |||
774 | def dirty(self, ignoreupdate=False): |
|
777 | def dirty(self, ignoreupdate=False): | |
|
778 | if self._gitmissing(): | |||
|
779 | return True | |||
775 | if not ignoreupdate and self._state[1] != self._gitstate(): |
|
780 | if not ignoreupdate and self._state[1] != self._gitstate(): | |
776 | # different version checked out |
|
781 | # different version checked out | |
777 | return True |
|
782 | return True | |
@@ -860,6 +865,8 class gitsubrepo(abstractsubrepo): | |||||
860 | rawcheckout() |
|
865 | rawcheckout() | |
861 |
|
866 | |||
862 | def commit(self, text, user, date): |
|
867 | def commit(self, text, user, date): | |
|
868 | if self._gitmissing(): | |||
|
869 | raise util.Abort(_("subrepo %s is missing") % self._relpath) | |||
863 | cmd = ['commit', '-a', '-m', text] |
|
870 | cmd = ['commit', '-a', '-m', text] | |
864 | env = os.environ.copy() |
|
871 | env = os.environ.copy() | |
865 | if user: |
|
872 | if user: | |
@@ -896,6 +903,8 class gitsubrepo(abstractsubrepo): | |||||
896 | mergefunc() |
|
903 | mergefunc() | |
897 |
|
904 | |||
898 | def push(self, force): |
|
905 | def push(self, force): | |
|
906 | if self._gitmissing(): | |||
|
907 | raise util.Abort(_("subrepo %s is missing") % self._relpath) | |||
899 | # if a branch in origin contains the revision, nothing to do |
|
908 | # if a branch in origin contains the revision, nothing to do | |
900 | branch2rev, rev2branch = self._gitbranchmap() |
|
909 | branch2rev, rev2branch = self._gitbranchmap() | |
901 | if self._state[1] in rev2branch: |
|
910 | if self._state[1] in rev2branch: | |
@@ -929,6 +938,8 class gitsubrepo(abstractsubrepo): | |||||
929 | return False |
|
938 | return False | |
930 |
|
939 | |||
931 | def remove(self): |
|
940 | def remove(self): | |
|
941 | if self._gitmissing(): | |||
|
942 | return | |||
932 | if self.dirty(): |
|
943 | if self.dirty(): | |
933 | self._ui.warn(_('not removing repo %s because ' |
|
944 | self._ui.warn(_('not removing repo %s because ' | |
934 | 'it has changes.\n') % self._relpath) |
|
945 | 'it has changes.\n') % self._relpath) | |
@@ -972,6 +983,9 class gitsubrepo(abstractsubrepo): | |||||
972 |
|
983 | |||
973 |
|
984 | |||
974 | def status(self, rev2, **opts): |
|
985 | def status(self, rev2, **opts): | |
|
986 | if self._gitmissing(): | |||
|
987 | # if the repo is missing, return no results | |||
|
988 | return [], [], [], [], [], [], [] | |||
975 | rev1 = self._state[1] |
|
989 | rev1 = self._state[1] | |
976 | modified, added, removed = [], [], [] |
|
990 | modified, added, removed = [], [], [] | |
977 | if rev2: |
|
991 | if rev2: |
@@ -314,6 +314,26 relative source expansion | |||||
314 | cloning subrepo s |
|
314 | cloning subrepo s | |
315 | 3 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
315 | 3 files updated, 0 files merged, 0 files removed, 0 files unresolved | |
316 |
|
316 | |||
|
317 | Don't crash if the subrepo is missing | |||
|
318 | ||||
|
319 | $ hg clone t missing -q | |||
|
320 | $ cd missing | |||
|
321 | $ rm -rf s | |||
|
322 | $ hg status -S | |||
|
323 | $ hg sum | grep commit | |||
|
324 | commit: 1 subrepos | |||
|
325 | $ hg push -q | |||
|
326 | abort: subrepo s is missing | |||
|
327 | [255] | |||
|
328 | $ hg commit -qm missing | |||
|
329 | abort: subrepo s is missing | |||
|
330 | [255] | |||
|
331 | $ hg update -C | |||
|
332 | cloning subrepo s | |||
|
333 | 1 files updated, 0 files merged, 0 files removed, 0 files unresolved | |||
|
334 | $ hg sum | grep commit | |||
|
335 | commit: (clean) | |||
|
336 | ||||
317 | Check hg update --clean |
|
337 | Check hg update --clean | |
318 | $ cd $TESTTMP/ta |
|
338 | $ cd $TESTTMP/ta | |
319 | $ echo > s/g |
|
339 | $ echo > s/g |
General Comments 0
You need to be logged in to leave comments.
Login now