##// END OF EJS Templates
exchange: ensure all outgoing subrepo references are present before pushing...
Matt Harbison -
r44365:4b7d5d10 default
parent child Browse files
Show More
@@ -646,6 +646,8 b' def push('
646 pushop.repo.checkpush(pushop)
646 pushop.repo.checkpush(pushop)
647 _checkpublish(pushop)
647 _checkpublish(pushop)
648 _pushdiscovery(pushop)
648 _pushdiscovery(pushop)
649 if not pushop.force:
650 _checksubrepostate(pushop)
649 if not _forcebundle1(pushop):
651 if not _forcebundle1(pushop):
650 _pushbundle2(pushop)
652 _pushbundle2(pushop)
651 _pushchangeset(pushop)
653 _pushchangeset(pushop)
@@ -694,6 +696,17 b' def _pushdiscovery(pushop):'
694 step(pushop)
696 step(pushop)
695
697
696
698
699 def _checksubrepostate(pushop):
700 """Ensure all outgoing referenced subrepo revisions are present locally"""
701 for n in pushop.outgoing.missing:
702 ctx = pushop.repo[n]
703
704 if b'.hgsub' in ctx.manifest() and b'.hgsubstate' in ctx.files():
705 for subpath in sorted(ctx.substate):
706 sub = ctx.sub(subpath)
707 sub.verify(onpush=True)
708
709
697 @pushdiscovery(b'changeset')
710 @pushdiscovery(b'changeset')
698 def _pushdiscoverychangeset(pushop):
711 def _pushdiscoverychangeset(pushop):
699 """discover the changeset that need to be pushed"""
712 """discover the changeset that need to be pushed"""
@@ -429,10 +429,12 b' class abstractsubrepo(object):'
429 convert this repository from shared to normal storage.
429 convert this repository from shared to normal storage.
430 '''
430 '''
431
431
432 def verify(self):
432 def verify(self, onpush=False):
433 '''verify the integrity of the repository. Return 0 on success or
433 """verify the revision of this repository that is held in `_state` is
434 warning, 1 on any error.
434 present and not hidden. Return 0 on success or warning, 1 on any
435 '''
435 error. In the case of ``onpush``, warnings or errors will raise an
436 exception if the result of pushing would be a broken remote repository.
437 """
436 return 0
438 return 0
437
439
438 @propertycache
440 @propertycache
@@ -1013,26 +1015,35 b' class hgsubrepo(abstractsubrepo):'
1013
1015
1014 hg.unshare(self.ui, self._repo)
1016 hg.unshare(self.ui, self._repo)
1015
1017
1016 def verify(self):
1018 def verify(self, onpush=False):
1017 try:
1019 try:
1018 rev = self._state[1]
1020 rev = self._state[1]
1019 ctx = self._repo.unfiltered()[rev]
1021 ctx = self._repo.unfiltered()[rev]
1020 if ctx.hidden():
1022 if ctx.hidden():
1021 # Since hidden revisions aren't pushed/pulled, it seems worth an
1023 # Since hidden revisions aren't pushed/pulled, it seems worth an
1022 # explicit warning.
1024 # explicit warning.
1023 ui = self._repo.ui
1025 msg = _(b"subrepo '%s' is hidden in revision %s") % (
1024 ui.warn(
1026 self._relpath,
1025 _(b"subrepo '%s' is hidden in revision %s\n")
1027 node.short(self._ctx.node()),
1026 % (self._relpath, node.short(self._ctx.node()))
1027 )
1028 )
1029
1030 if onpush:
1031 raise error.Abort(msg)
1032 else:
1033 self._repo.ui.warn(b'%s\n' % msg)
1028 return 0
1034 return 0
1029 except error.RepoLookupError:
1035 except error.RepoLookupError:
1030 # A missing subrepo revision may be a case of needing to pull it, so
1036 # A missing subrepo revision may be a case of needing to pull it, so
1031 # don't treat this as an error.
1037 # don't treat this as an error for `hg verify`.
1032 self._repo.ui.warn(
1038 msg = _(b"subrepo '%s' not found in revision %s") % (
1033 _(b"subrepo '%s' not found in revision %s\n")
1039 self._relpath,
1034 % (self._relpath, node.short(self._ctx.node()))
1040 node.short(self._ctx.node()),
1035 )
1041 )
1042
1043 if onpush:
1044 raise error.Abort(msg)
1045 else:
1046 self._repo.ui.warn(b'%s\n' % msg)
1036 return 0
1047 return 0
1037
1048
1038 @propertycache
1049 @propertycache
@@ -164,4 +164,35 b' amend with .hgsub removed'
164 R .hgsub
164 R .hgsub
165 R .hgsubstate
165 R .hgsubstate
166
166
167 broken repositories will refuse to push
168
169 #if obsstore-off
170 $ hg up -q -C 2
171 #else
172 $ hg up -q -C 6
173 #endif
174 $ echo c >> t/b
175 $ hg amend -q -R t
176
177 $ hg init ../dest
178 $ hg init ../dest/t
179 $ hg init ../dest/s
180 $ hg push -q ../dest
181 abort: subrepo 't' is hidden in revision 04aa62396ec6 (obsstore-on !)
182 abort: subrepo 't' not found in revision 04aa62396ec6 (obsstore-off !)
183 [255]
184
185 ... unless forced
186
187 $ hg push --force -q ../dest
188 $ hg verify -R ../dest
189 checking changesets
190 checking manifests
191 crosschecking files in changesets and manifests
192 checking files
193 checked 5 changesets with 12 changes to 4 files
194 checking subrepo links
195 subrepo 't' not found in revision 04aa62396ec6
196 subrepo 't' not found in revision 6bce99600681
197
167 $ cd ..
198 $ cd ..
General Comments 0
You need to be logged in to leave comments. Login now