comparison mercurial/subrepo.py @ 34879:7d51a7792f52

subrepo: implement 'unshare' for Mercurial subrepos I think there's a slight hole here in that a subrepo could be shared, removed from .hgsub, and then it's not part of context.substate (so not iterated over). But the push command has the same hole IIRC, and I think removing a subrepo is an edge case. The import hack is a copy/paste of subrepo.subrepo().
author Matt Harbison <matt_harbison@yahoo.com>
date Tue, 17 Oct 2017 22:55:33 -0400
parents 68e0bcb90357
children 071cbeba4212
comparison
equal deleted inserted replaced
34878:9f7ecc5bbc28 34879:7d51a7792f52
619 return [] 619 return []
620 620
621 def shortid(self, revid): 621 def shortid(self, revid):
622 return revid 622 return revid
623 623
624 def unshare(self):
625 '''
626 convert this repository from shared to normal storage.
627 '''
628
624 def verify(self): 629 def verify(self):
625 '''verify the integrity of the repository. Return 0 on success or 630 '''verify the integrity of the repository. Return 0 on success or
626 warning, 1 on any error. 631 warning, 1 on any error.
627 ''' 632 '''
628 return 0 633 return 0
1080 pats = [] 1085 pats = []
1081 cmdutil.revert(self.ui, self._repo, ctx, parents, *pats, **opts) 1086 cmdutil.revert(self.ui, self._repo, ctx, parents, *pats, **opts)
1082 1087
1083 def shortid(self, revid): 1088 def shortid(self, revid):
1084 return revid[:12] 1089 return revid[:12]
1090
1091 @annotatesubrepoerror
1092 def unshare(self):
1093 # subrepo inherently violates our import layering rules
1094 # because it wants to make repo objects from deep inside the stack
1095 # so we manually delay the circular imports to not break
1096 # scripts that don't use our demand-loading
1097 global hg
1098 from . import hg as h
1099 hg = h
1100
1101 # Nothing prevents a user from sharing in a repo, and then making that a
1102 # subrepo. Alternately, the previous unshare attempt may have failed
1103 # part way through. So recurse whether or not this layer is shared.
1104 if self._repo.shared():
1105 self.ui.status(_("unsharing subrepo '%s'\n") % self._relpath)
1106
1107 hg.unshare(self.ui, self._repo)
1085 1108
1086 def verify(self): 1109 def verify(self):
1087 try: 1110 try:
1088 rev = self._state[1] 1111 rev = self._state[1]
1089 ctx = self._repo.unfiltered()[rev] 1112 ctx = self._repo.unfiltered()[rev]