##// END OF EJS Templates
subrepo: don't crash when git .hgsubstate is empty (issue2716)
Eric Eisner -
r14469:2fdea636 stable
parent child Browse files
Show More
@@ -808,7 +808,7 b' class gitsubrepo(abstractsubrepo):'
808 808
809 809 def dirty(self, ignoreupdate=False):
810 810 if self._gitmissing():
811 return True
811 return self._state[1] != ''
812 812 if not ignoreupdate and self._state[1] != self._gitstate():
813 813 # different version checked out
814 814 return True
@@ -818,6 +818,9 b' class gitsubrepo(abstractsubrepo):'
818 818
819 819 def get(self, state, overwrite=False):
820 820 source, revision, kind = state
821 if not revision:
822 self.remove()
823 return
821 824 self._fetch(source, revision)
822 825 # if the repo was set to be bare, unbare it
823 826 if self._gitcommand(['config', '--bool', 'core.bare']) == 'true':
@@ -935,6 +938,8 b' class gitsubrepo(abstractsubrepo):'
935 938 mergefunc()
936 939
937 940 def push(self, force):
941 if not self._state[1]:
942 return True
938 943 if self._gitmissing():
939 944 raise util.Abort(_("subrepo %s is missing") % self._relpath)
940 945 # if a branch in origin contains the revision, nothing to do
@@ -991,6 +996,8 b' class gitsubrepo(abstractsubrepo):'
991 996
992 997 def archive(self, ui, archiver, prefix):
993 998 source, revision = self._state
999 if not revision:
1000 return
994 1001 self._fetch(source, revision)
995 1002
996 1003 # Parse git's native archive command.
@@ -1015,10 +1022,10 b' class gitsubrepo(abstractsubrepo):'
1015 1022
1016 1023
1017 1024 def status(self, rev2, **opts):
1018 if self._gitmissing():
1025 rev1 = self._state[1]
1026 if self._gitmissing() or not rev1:
1019 1027 # if the repo is missing, return no results
1020 1028 return [], [], [], [], [], [], []
1021 rev1 = self._state[1]
1022 1029 modified, added, removed = [], [], []
1023 1030 if rev2:
1024 1031 command = ['diff-tree', rev1, rev2]
@@ -334,6 +334,33 b" Don't crash if the subrepo is missing"
334 334 $ hg sum | grep commit
335 335 commit: (clean)
336 336
337 Don't crash if the .hgsubstate entry is missing
338
339 $ hg update 1 -q
340 $ hg rm .hgsubstate
341 $ hg commit .hgsubstate -m 'no substate'
342 created new head
343 $ hg tag -l nosubstate
344 $ hg manifest
345 .hgsub
346 a
347
348 $ hg status -S
349 $ hg sum | grep commit
350 commit: 1 subrepos
351
352 $ hg commit -m 'restore substate'
353 committing subrepository s
354 $ hg manifest
355 .hgsub
356 .hgsubstate
357 a
358 $ hg sum | grep commit
359 commit: (clean)
360
361 $ hg update -qC nosubstate
362 $ ls s
363
337 364 Check hg update --clean
338 365 $ cd $TESTTMP/ta
339 366 $ echo > s/g
General Comments 0
You need to be logged in to leave comments. Login now