Show More
@@ -24,8 +24,7 b' import basestore' | |||||
24 | # -- Utility functions: commonly/repeatedly needed functionality --------------- |
|
24 | # -- Utility functions: commonly/repeatedly needed functionality --------------- | |
25 |
|
25 | |||
26 | def installnormalfilesmatchfn(manifest): |
|
26 | def installnormalfilesmatchfn(manifest): | |
27 | '''overrides scmutil.match so that the matcher it returns will ignore all |
|
27 | '''installmatchfn with a matchfn that ignores all largefiles''' | |
28 | largefiles''' |
|
|||
29 | oldmatch = None # for the closure |
|
28 | oldmatch = None # for the closure | |
30 | def overridematch(ctx, pats=[], opts={}, globbed=False, |
|
29 | def overridematch(ctx, pats=[], opts={}, globbed=False, | |
31 | default='relpath'): |
|
30 | default='relpath'): | |
@@ -42,16 +41,18 b' def installnormalfilesmatchfn(manifest):' | |||||
42 | oldmatch = installmatchfn(overridematch) |
|
41 | oldmatch = installmatchfn(overridematch) | |
43 |
|
42 | |||
44 | def installmatchfn(f): |
|
43 | def installmatchfn(f): | |
|
44 | '''monkey patch the scmutil module with a custom match function. | |||
|
45 | Warning: it is monkey patching the _module_ on runtime! Not thread safe!''' | |||
45 | oldmatch = scmutil.match |
|
46 | oldmatch = scmutil.match | |
46 | setattr(f, 'oldmatch', oldmatch) |
|
47 | setattr(f, 'oldmatch', oldmatch) | |
47 | scmutil.match = f |
|
48 | scmutil.match = f | |
48 | return oldmatch |
|
49 | return oldmatch | |
49 |
|
50 | |||
50 | def restorematchfn(): |
|
51 | def restorematchfn(): | |
51 |
'''restores scmutil.match to what it was before install |
|
52 | '''restores scmutil.match to what it was before installmatchfn | |
52 | was called. no-op if scmutil.match is its original function. |
|
53 | was called. no-op if scmutil.match is its original function. | |
53 |
|
54 | |||
54 |
Note that n calls to install |
|
55 | Note that n calls to installmatchfn will require n calls to | |
55 | restore matchfn to reverse''' |
|
56 | restore matchfn to reverse''' | |
56 | scmutil.match = getattr(scmutil.match, 'oldmatch', scmutil.match) |
|
57 | scmutil.match = getattr(scmutil.match, 'oldmatch', scmutil.match) | |
57 |
|
58 |
General Comments 0
You need to be logged in to leave comments.
Login now