comparison mercurial/bundle2.py @ 31647:4dbef666c6c9

bundle2: use ProgrammingError
author Jun Wu <quark@fb.com>
date Sun, 26 Mar 2017 16:57:25 -0700
parents 413b44003462
children 6d055cd6669f
comparison
equal deleted inserted replaced
31646:e960eba3581c 31647:4dbef666c6c9
853 self._advisoryparams = list(advisoryparams) 853 self._advisoryparams = list(advisoryparams)
854 # checking for duplicated entries 854 # checking for duplicated entries
855 self._seenparams = set() 855 self._seenparams = set()
856 for pname, __ in self._mandatoryparams + self._advisoryparams: 856 for pname, __ in self._mandatoryparams + self._advisoryparams:
857 if pname in self._seenparams: 857 if pname in self._seenparams:
858 raise RuntimeError('duplicated params: %s' % pname) 858 raise error.ProgrammingError('duplicated params: %s' % pname)
859 self._seenparams.add(pname) 859 self._seenparams.add(pname)
860 # status of the part's generation: 860 # status of the part's generation:
861 # - None: not started, 861 # - None: not started,
862 # - False: currently generated, 862 # - False: currently generated,
863 # - True: generation done. 863 # - True: generation done.
911 params.append((name, value)) 911 params.append((name, value))
912 912
913 # methods used to generates the bundle2 stream 913 # methods used to generates the bundle2 stream
914 def getchunks(self, ui): 914 def getchunks(self, ui):
915 if self._generated is not None: 915 if self._generated is not None:
916 raise RuntimeError('part can only be consumed once') 916 raise error.ProgrammingError('part can only be consumed once')
917 self._generated = False 917 self._generated = False
918 918
919 if ui.debugflag: 919 if ui.debugflag:
920 msg = ['bundle2-output-part: "%s"' % self.type] 920 msg = ['bundle2-output-part: "%s"' % self.type]
921 if not self.mandatory: 921 if not self.mandatory:
1080 self.reply = None 1080 self.reply = None
1081 self.captureoutput = False 1081 self.captureoutput = False
1082 1082
1083 @property 1083 @property
1084 def repo(self): 1084 def repo(self):
1085 raise RuntimeError('no repo access from stream interruption') 1085 raise error.ProgrammingError('no repo access from stream interruption')
1086 1086
1087 def gettransaction(self): 1087 def gettransaction(self):
1088 raise TransactionUnavailable('no repo access from stream interruption') 1088 raise TransactionUnavailable('no repo access from stream interruption')
1089 1089
1090 class unbundlepart(unpackermixin): 1090 class unbundlepart(unpackermixin):