Mercurial > hg
comparison hgext/largefiles/reposetup.py @ 23186:6de61d0b773f
largefiles: introduce "_lfcommithooks" to abstract pre-committing procedures
This changes allows to customize pre-committing procedures according
to conditions.
This patch uses "stack" with an element instead of flag like
"_isXXXXing" or so, because:
- the former works correctly even when customizations are nested, and
- ensuring at least one element can ignore empty check
author | FUJIWARA Katsunori <foozy@lares.dti.ne.jp> |
---|---|
date | Wed, 05 Nov 2014 23:24:47 +0900 |
parents | 9870173e0b48 |
children | 94ac64bcf6fe |
comparison
equal
deleted
inserted
replaced
23185:9870173e0b48 | 23186:6de61d0b773f |
---|---|
260 force=False, editor=False, extra={}): | 260 force=False, editor=False, extra={}): |
261 orig = super(lfilesrepo, self).commit | 261 orig = super(lfilesrepo, self).commit |
262 | 262 |
263 wlock = self.wlock() | 263 wlock = self.wlock() |
264 try: | 264 try: |
265 match = lfutil.updatestandinsbymatch(self, match) | 265 lfcommithook = self._lfcommithooks[-1] |
266 match = lfcommithook(self, match) | |
266 result = orig(text=text, user=user, date=date, match=match, | 267 result = orig(text=text, user=user, date=date, match=match, |
267 force=force, editor=editor, extra=extra) | 268 force=force, editor=editor, extra=extra) |
268 return result | 269 return result |
269 finally: | 270 finally: |
270 wlock.release() | 271 wlock.release() |
336 actualfiles += regulars | 337 actualfiles += regulars |
337 return actualfiles | 338 return actualfiles |
338 | 339 |
339 repo.__class__ = lfilesrepo | 340 repo.__class__ = lfilesrepo |
340 | 341 |
342 # stack of hooks being executed before committing. | |
343 # only last element ("_lfcommithooks[-1]") is used for each committing. | |
344 repo._lfcommithooks = [lfutil.updatestandinsbymatch] | |
345 | |
341 def prepushoutgoinghook(local, remote, outgoing): | 346 def prepushoutgoinghook(local, remote, outgoing): |
342 if outgoing.missing: | 347 if outgoing.missing: |
343 toupload = set() | 348 toupload = set() |
344 addfunc = lambda fn, lfhash: toupload.add(lfhash) | 349 addfunc = lambda fn, lfhash: toupload.add(lfhash) |
345 lfutil.getlfilestoupload(local, outgoing.missing, addfunc) | 350 lfutil.getlfilestoupload(local, outgoing.missing, addfunc) |