##// 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 copies as copiesmod,
24 copies as copiesmod,
25 error,
25 error,
26 exchange,
26 exchange,
27 extensions,
27 exthelper,
28 exthelper,
28 filemerge,
29 filemerge,
29 hg,
30 hg,
@@ -103,22 +104,6 b' def restorematchfn():'
103 restore the original matchfn.'''
104 restore the original matchfn.'''
104 scmutil.match = getattr(scmutil.match, 'oldmatch')
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 def addlargefiles(ui, repo, isaddremove, matcher, **opts):
107 def addlargefiles(ui, repo, isaddremove, matcher, **opts):
123 large = opts.get(r'large')
108 large = opts.get(r'large')
124 lfsize = lfutil.getminsize(
109 lfsize = lfutil.getminsize(
@@ -324,7 +309,7 b' def overridedirty(orig, repo, ignoreupda'
324
309
325 @eh.wrapcommand('log')
310 @eh.wrapcommand('log')
326 def overridelog(orig, ui, repo, *pats, **opts):
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 default='relpath', badfn=None):
313 default='relpath', badfn=None):
329 """Matcher that merges root directory with .hglf, suitable for log.
314 """Matcher that merges root directory with .hglf, suitable for log.
330 It is still possible to match .hglf directly.
315 It is still possible to match .hglf directly.
@@ -333,8 +318,7 b' def overridelog(orig, ui, repo, *pats, *'
333 """
318 """
334 if opts is None:
319 if opts is None:
335 opts = {}
320 opts = {}
336 matchandpats = oldmatchandpats(ctx, pats, opts, globbed, default,
321 matchandpats = orig(ctx, pats, opts, globbed, default, badfn=badfn)
337 badfn=badfn)
338 m, p = copy.copy(matchandpats)
322 m, p = copy.copy(matchandpats)
339
323
340 if m.always():
324 if m.always():
@@ -414,20 +398,18 b' def overridelog(orig, ui, repo, *pats, *'
414 # (2) to determine what files to print out diffs for.
398 # (2) to determine what files to print out diffs for.
415 # The magic matchandpats override should be used for case (1) but not for
399 # The magic matchandpats override should be used for case (1) but not for
416 # case (2).
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 wctx = repo[None]
403 wctx = repo[None]
419 match, pats = oldmatchandpats(wctx, pats, opts, badfn=badfn)
404 match, pats = oldmatchandpats(wctx, pats, opts, badfn=badfn)
420 return lambda ctx: match
405 return lambda ctx: match
421
406
422 oldmatchandpats = installmatchandpatsfn(overridematchandpats)
407 wrappedmatchandpats = extensions.wrappedfunction(scmutil, 'matchandpats',
423 oldmakefilematcher = logcmdutil._makenofollowfilematcher
408 overridematchandpats)
424 setattr(logcmdutil, '_makenofollowfilematcher', overridemakefilematcher)
409 wrappedmakefilematcher = extensions.wrappedfunction(
425
410 logcmdutil, '_makenofollowfilematcher', overridemakefilematcher)
426 try:
411 with wrappedmatchandpats, wrappedmakefilematcher:
427 return orig(ui, repo, *pats, **opts)
412 return orig(ui, repo, *pats, **opts)
428 finally:
429 restorematchandpatsfn()
430 setattr(logcmdutil, '_makenofollowfilematcher', oldmakefilematcher)
431
413
432 @eh.wrapcommand('verify',
414 @eh.wrapcommand('verify',
433 opts=[('', 'large', None,
415 opts=[('', 'large', None,
General Comments 0
You need to be logged in to leave comments. Login now