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