Patchwork [5,of,9,V2] largefiles: introduce "_lfcommithooks" to abstract pre-committing procedures

login
register
mail settings
Submitter Katsunori FUJIWARA
Date Nov. 5, 2014, 2:34 p.m.
Message ID <6de61d0b773f912010d1.1415198054@feefifofum>
Download mbox | patch
Permalink /patch/6575/
State Accepted
Headers show

Comments

Katsunori FUJIWARA - Nov. 5, 2014, 2:34 p.m.
# HG changeset patch
# User FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
# Date 1415197487 -32400
#      Wed Nov 05 23:24:47 2014 +0900
# Node ID 6de61d0b773f912010d137efc78cc47409c06d71
# Parent  9870173e0b4888c5629390b35f5173ce5abee43d
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

Patch

diff --git a/hgext/largefiles/reposetup.py b/hgext/largefiles/reposetup.py
--- a/hgext/largefiles/reposetup.py
+++ b/hgext/largefiles/reposetup.py
@@ -262,7 +262,8 @@ 
 
             wlock = self.wlock()
             try:
-                match = lfutil.updatestandinsbymatch(self, match)
+                lfcommithook = self._lfcommithooks[-1]
+                match = lfcommithook(self, match)
                 result = orig(text=text, user=user, date=date, match=match,
                                 force=force, editor=editor, extra=extra)
                 return result
@@ -338,6 +339,10 @@ 
 
     repo.__class__ = lfilesrepo
 
+    # stack of hooks being executed before committing.
+    # only last element ("_lfcommithooks[-1]") is used for each committing.
+    repo._lfcommithooks = [lfutil.updatestandinsbymatch]
+
     def prepushoutgoinghook(local, remote, outgoing):
         if outgoing.missing:
             toupload = set()