##// END OF EJS Templates
subrepo: be more careful with deletions of .hgsub and .hgsubstate (issue2844)...
Matt Mackall -
r14536:52cbeb5a default
parent child Browse files
Show More
@@ -944,6 +944,8 b' class localrepository(repo.repository):'
944 # check subrepos
944 # check subrepos
945 subs = []
945 subs = []
946 removedsubs = set()
946 removedsubs = set()
947 if '.hgsub' in wctx:
948 # only manage subrepos and .hgsubstate if .hgsub is present
947 for p in wctx.parents():
949 for p in wctx.parents():
948 removedsubs.update(s for s in p.substate if match(s))
950 removedsubs.update(s for s in p.substate if match(s))
949 for s in wctx.substate:
951 for s in wctx.substate:
@@ -953,9 +955,17 b' class localrepository(repo.repository):'
953 if (subs or removedsubs):
955 if (subs or removedsubs):
954 if (not match('.hgsub') and
956 if (not match('.hgsub') and
955 '.hgsub' in (wctx.modified() + wctx.added())):
957 '.hgsub' in (wctx.modified() + wctx.added())):
956 raise util.Abort(_("can't commit subrepos without .hgsub"))
958 raise util.Abort(
959 _("can't commit subrepos without .hgsub"))
957 if '.hgsubstate' not in changes[0]:
960 if '.hgsubstate' not in changes[0]:
958 changes[0].insert(0, '.hgsubstate')
961 changes[0].insert(0, '.hgsubstate')
962 if '.hgsubstate' in changes[2]:
963 changes[2].remove('.hgsubstate')
964 elif '.hgsub' in changes[2]:
965 # clean up .hgsubstate when .hgsub is removed
966 if ('.hgsubstate' in wctx and
967 '.hgsubstate' not in changes[0] + changes[1] + changes[2]):
968 changes[2].insert(0, '.hgsubstate')
959
969
960 if subs and not self.ui.configbool('ui', 'commitsubrepos', True):
970 if subs and not self.ui.configbool('ui', 'commitsubrepos', True):
961 changedsubs = [s for s in subs if wctx.sub(s).dirty(True)]
971 changedsubs = [s for s in subs if wctx.sub(s).dirty(True)]
@@ -500,6 +500,7 b' test subrepo delete from .hgsubstate'
500 $ hg -R testdelete remove testdelete/.hgsub
500 $ hg -R testdelete remove testdelete/.hgsub
501 $ hg -R testdelete ci -m ".hgsub deleted"
501 $ hg -R testdelete ci -m ".hgsub deleted"
502 $ cat testdelete/.hgsubstate
502 $ cat testdelete/.hgsubstate
503 bdf5c9a3103743d900b12ae0db3ffdcfd7b0d878 nested
503
504
504 test repository cloning
505 test repository cloning
505
506
@@ -823,3 +824,36 b' Test subrepo already at intended revisio'
823 fc627a69481f
824 fc627a69481f
824 $ hg -R t id
825 $ hg -R t id
825 e95bcfa18a35
826 e95bcfa18a35
827
828 Test that removing .hgsubstate doesn't break anything:
829
830 $ hg rm -f .hgsubstate
831 $ hg ci -mrm
832 committing subrepository s
833 committing subrepository t
834 created new head
835 $ hg log -vr tip
836 changeset: 14:3941e0aa5236
837 tag: tip
838 parent: 11:365661e5936a
839 user: test
840 date: Thu Jan 01 00:00:00 1970 +0000
841 description:
842 rm
843
844
845
846 Test that removing .hgsub removes .hgsubstate:
847
848 $ hg rm .hgsub
849 $ hg ci -mrm2
850 $ hg log -vr tip
851 changeset: 15:8b31de9d13d1
852 tag: tip
853 user: test
854 date: Thu Jan 01 00:00:00 1970 +0000
855 files: .hgsub .hgsubstate
856 description:
857 rm2
858
859
General Comments 0
You need to be logged in to leave comments. Login now