##// END OF EJS Templates
largefiles: use wrappedfunction() for matchandpats() override in overridelog()...
Martin von Zweigbergk -
r41719:8d1dc380 default
parent child Browse files
Show More
@@ -24,6 +24,7 b' from mercurial import ('
24 24 copies as copiesmod,
25 25 error,
26 26 exchange,
27 extensions,
27 28 exthelper,
28 29 filemerge,
29 30 hg,
@@ -103,22 +104,6 b' def restorematchfn():'
103 104 restore the original matchfn.'''
104 105 scmutil.match = getattr(scmutil.match, 'oldmatch')
105 106
106 def installmatchandpatsfn(f):
107 oldmatchandpats = scmutil.matchandpats
108 setattr(f, 'oldmatchandpats', oldmatchandpats)
109 scmutil.matchandpats = f
110 return oldmatchandpats
111
112 def restorematchandpatsfn():
113 '''restores scmutil.matchandpats to what it was before
114 installmatchandpatsfn was called. No-op if scmutil.matchandpats
115 is its original function.
116
117 Note that n calls to installmatchandpatsfn will require n calls
118 to restore the original matchfn.'''
119 scmutil.matchandpats = getattr(scmutil.matchandpats, 'oldmatchandpats',
120 scmutil.matchandpats)
121
122 107 def addlargefiles(ui, repo, isaddremove, matcher, **opts):
123 108 large = opts.get(r'large')
124 109 lfsize = lfutil.getminsize(
@@ -324,7 +309,7 b' def overridedirty(orig, repo, ignoreupda'
324 309
325 310 @eh.wrapcommand('log')
326 311 def overridelog(orig, ui, repo, *pats, **opts):
327 def overridematchandpats(ctx, pats=(), opts=None, globbed=False,
312 def overridematchandpats(orig, ctx, pats=(), opts=None, globbed=False,
328 313 default='relpath', badfn=None):
329 314 """Matcher that merges root directory with .hglf, suitable for log.
330 315 It is still possible to match .hglf directly.
@@ -333,8 +318,7 b' def overridelog(orig, ui, repo, *pats, *'
333 318 """
334 319 if opts is None:
335 320 opts = {}
336 matchandpats = oldmatchandpats(ctx, pats, opts, globbed, default,
337 badfn=badfn)
321 matchandpats = orig(ctx, pats, opts, globbed, default, badfn=badfn)
338 322 m, p = copy.copy(matchandpats)
339 323
340 324 if m.always():
@@ -414,20 +398,18 b' def overridelog(orig, ui, repo, *pats, *'
414 398 # (2) to determine what files to print out diffs for.
415 399 # The magic matchandpats override should be used for case (1) but not for
416 400 # case (2).
417 def overridemakefilematcher(repo, pats, opts, badfn=None):
401 oldmatchandpats = scmutil.matchandpats
402 def overridemakefilematcher(orig, repo, pats, opts, badfn=None):
418 403 wctx = repo[None]
419 404 match, pats = oldmatchandpats(wctx, pats, opts, badfn=badfn)
420 405 return lambda ctx: match
421 406
422 oldmatchandpats = installmatchandpatsfn(overridematchandpats)
423 oldmakefilematcher = logcmdutil._makenofollowfilematcher
424 setattr(logcmdutil, '_makenofollowfilematcher', overridemakefilematcher)
425
426 try:
407 wrappedmatchandpats = extensions.wrappedfunction(scmutil, 'matchandpats',
408 overridematchandpats)
409 wrappedmakefilematcher = extensions.wrappedfunction(
410 logcmdutil, '_makenofollowfilematcher', overridemakefilematcher)
411 with wrappedmatchandpats, wrappedmakefilematcher:
427 412 return orig(ui, repo, *pats, **opts)
428 finally:
429 restorematchandpatsfn()
430 setattr(logcmdutil, '_makenofollowfilematcher', oldmakefilematcher)
431 413
432 414 @eh.wrapcommand('verify',
433 415 opts=[('', 'large', None,
General Comments 0
You need to be logged in to leave comments. Login now