##// END OF EJS Templates
sidedata: add a way of replacing an existing sidedata computer...
Raphaël Gomès -
r47846:81eb7091 default
parent child Browse files
Show More
@@ -1856,7 +1856,9 b' class ilocalrepositorymain(interfaceutil'
1856 def savecommitmessage(text):
1856 def savecommitmessage(text):
1857 pass
1857 pass
1858
1858
1859 def register_sidedata_computer(kind, category, keys, computer, flags):
1859 def register_sidedata_computer(
1860 kind, category, keys, computer, flags, replace=False
1861 ):
1860 pass
1862 pass
1861
1863
1862 def register_wanted_sidedata(category):
1864 def register_wanted_sidedata(category):
@@ -3370,16 +3370,25 b' class localrepository(object):'
3370 return
3370 return
3371 self._wanted_sidedata.add(pycompat.bytestr(category))
3371 self._wanted_sidedata.add(pycompat.bytestr(category))
3372
3372
3373 def register_sidedata_computer(self, kind, category, keys, computer, flags):
3373 def register_sidedata_computer(
3374 self, kind, category, keys, computer, flags, replace=False
3375 ):
3374 if kind not in revlogconst.ALL_KINDS:
3376 if kind not in revlogconst.ALL_KINDS:
3375 msg = _(b"unexpected revlog kind '%s'.")
3377 msg = _(b"unexpected revlog kind '%s'.")
3376 raise error.ProgrammingError(msg % kind)
3378 raise error.ProgrammingError(msg % kind)
3377 category = pycompat.bytestr(category)
3379 category = pycompat.bytestr(category)
3378 if category in self._sidedata_computers.get(kind, []):
3380 already_registered = category in self._sidedata_computers.get(kind, [])
3381 if already_registered and not replace:
3379 msg = _(
3382 msg = _(
3380 b"cannot register a sidedata computer twice for category '%s'."
3383 b"cannot register a sidedata computer twice for category '%s'."
3381 )
3384 )
3382 raise error.ProgrammingError(msg % category)
3385 raise error.ProgrammingError(msg % category)
3386 if replace and not already_registered:
3387 msg = _(
3388 b"cannot replace a sidedata computer that isn't registered "
3389 b"for category '%s'."
3390 )
3391 raise error.ProgrammingError(msg % category)
3383 self._sidedata_computers.setdefault(kind, {})
3392 self._sidedata_computers.setdefault(kind, {})
3384 self._sidedata_computers[kind][category] = (keys, computer, flags)
3393 self._sidedata_computers[kind][category] = (keys, computer, flags)
3385
3394
General Comments 0
You need to be logged in to leave comments. Login now