##// END OF EJS Templates
scmutil: pass a matcher to scmutil.addremove() instead of a list of patterns...
Matt Harbison -
r23533:891aaa7c default
parent child Browse files
Show More
@@ -94,7 +94,8 b' def perfaddremove(ui, repo):'
94 try:
94 try:
95 oldquiet = repo.ui.quiet
95 oldquiet = repo.ui.quiet
96 repo.ui.quiet = True
96 repo.ui.quiet = True
97 timer(lambda: scmutil.addremove(repo, dry_run=True))
97 matcher = scmutil.match(repo[None])
98 timer(lambda: scmutil.addremove(repo, matcher, dry_run=True))
98 finally:
99 finally:
99 repo.ui.quiet = oldquiet
100 repo.ui.quiet = oldquiet
100 fm.end()
101 fm.end()
@@ -73,7 +73,7 b' def restorematchandpatsfn():'
73 scmutil.matchandpats = getattr(scmutil.matchandpats, 'oldmatchandpats',
73 scmutil.matchandpats = getattr(scmutil.matchandpats, 'oldmatchandpats',
74 scmutil.matchandpats)
74 scmutil.matchandpats)
75
75
76 def addlargefiles(ui, repo, *pats, **opts):
76 def addlargefiles(ui, repo, matcher, **opts):
77 large = opts.pop('large', None)
77 large = opts.pop('large', None)
78 lfsize = lfutil.getminsize(
78 lfsize = lfutil.getminsize(
79 ui, lfutil.islfilesrepo(repo), opts.pop('lfsize', None))
79 ui, lfutil.islfilesrepo(repo), opts.pop('lfsize', None))
@@ -85,7 +85,7 b' def addlargefiles(ui, repo, *pats, **opt'
85 lfmatcher = match_.match(repo.root, '', list(lfpats))
85 lfmatcher = match_.match(repo.root, '', list(lfpats))
86
86
87 lfnames = []
87 lfnames = []
88 m = scmutil.match(repo[None], pats, opts)
88 m = copy.copy(matcher)
89 m.bad = lambda x, y: None
89 m.bad = lambda x, y: None
90 wctx = repo[None]
90 wctx = repo[None]
91 for f in repo.walk(m):
91 for f in repo.walk(m):
@@ -223,7 +223,8 b' def overrideadd(orig, ui, repo, *pats, *'
223 if opts.get('large'):
223 if opts.get('large'):
224 raise util.Abort(_('--normal cannot be used with --large'))
224 raise util.Abort(_('--normal cannot be used with --large'))
225 return orig(ui, repo, *pats, **opts)
225 return orig(ui, repo, *pats, **opts)
226 bad = addlargefiles(ui, repo, *pats, **opts)
226 matcher = scmutil.match(repo[None], pats, opts)
227 bad = addlargefiles(ui, repo, matcher, **opts)
227 installnormalfilesmatchfn(repo[None].manifest())
228 installnormalfilesmatchfn(repo[None].manifest())
228 result = orig(ui, repo, *pats, **opts)
229 result = orig(ui, repo, *pats, **opts)
229 restorematchfn()
230 restorematchfn()
@@ -1083,10 +1084,10 b' def overridesummary(orig, ui, repo, *pat'
1083 finally:
1084 finally:
1084 repo.lfstatus = False
1085 repo.lfstatus = False
1085
1086
1086 def scmutiladdremove(orig, repo, pats=[], opts={}, dry_run=None,
1087 def scmutiladdremove(orig, repo, matcher, opts={}, dry_run=None,
1087 similarity=None):
1088 similarity=None):
1088 if not lfutil.islfilesrepo(repo):
1089 if not lfutil.islfilesrepo(repo):
1089 return orig(repo, pats, opts, dry_run, similarity)
1090 return orig(repo, matcher, opts, dry_run, similarity)
1090 # Get the list of missing largefiles so we can remove them
1091 # Get the list of missing largefiles so we can remove them
1091 lfdirstate = lfutil.openlfdirstate(repo.ui, repo)
1092 lfdirstate = lfutil.openlfdirstate(repo.ui, repo)
1092 unsure, s = lfdirstate.status(match_.always(repo.root, repo.getcwd()), [],
1093 unsure, s = lfdirstate.status(match_.always(repo.root, repo.getcwd()), [],
@@ -1101,14 +1102,12 b' def scmutiladdremove(orig, repo, pats=[]'
1101 removelargefiles(repo.ui, repo, True, *m, **opts)
1102 removelargefiles(repo.ui, repo, True, *m, **opts)
1102 # Call into the normal add code, and any files that *should* be added as
1103 # Call into the normal add code, and any files that *should* be added as
1103 # largefiles will be
1104 # largefiles will be
1104 addlargefiles(repo.ui, repo, *pats, **opts)
1105 addlargefiles(repo.ui, repo, matcher, **opts)
1105 # Now that we've handled largefiles, hand off to the original addremove
1106 # Now that we've handled largefiles, hand off to the original addremove
1106 # function to take care of the rest. Make sure it doesn't do anything with
1107 # function to take care of the rest. Make sure it doesn't do anything with
1107 # largefiles by installing a matcher that will ignore them.
1108 # largefiles by passing a matcher that will ignore them.
1108 installnormalfilesmatchfn(repo[None].manifest())
1109 matcher = composenormalfilematcher(matcher, repo[None].manifest())
1109 result = orig(repo, pats, opts, dry_run, similarity)
1110 return orig(repo, matcher, opts, dry_run, similarity)
1110 restorematchfn()
1111 return result
1112
1111
1113 # Calling purge with --all will cause the largefiles to be deleted.
1112 # Calling purge with --all will cause the largefiles to be deleted.
1114 # Override repo.status to prevent this from happening.
1113 # Override repo.status to prevent this from happening.
@@ -2197,14 +2197,14 b' def commit(ui, repo, commitfunc, pats, o'
2197 if date:
2197 if date:
2198 opts['date'] = util.parsedate(date)
2198 opts['date'] = util.parsedate(date)
2199 message = logmessage(ui, opts)
2199 message = logmessage(ui, opts)
2200 matcher = scmutil.match(repo[None], pats, opts)
2200
2201
2201 # extract addremove carefully -- this function can be called from a command
2202 # extract addremove carefully -- this function can be called from a command
2202 # that doesn't support addremove
2203 # that doesn't support addremove
2203 if opts.get('addremove'):
2204 if opts.get('addremove'):
2204 scmutil.addremove(repo, pats, opts)
2205 scmutil.addremove(repo, matcher, opts)
2205
2206
2206 return commitfunc(ui, repo, message,
2207 return commitfunc(ui, repo, message, matcher, opts)
2207 scmutil.match(repo[None], pats, opts), opts)
2208
2208
2209 def amend(ui, repo, commitfunc, old, extra, pats, opts):
2209 def amend(ui, repo, commitfunc, old, extra, pats, opts):
2210 # amend will reuse the existing user if not specified, but the obsolete
2210 # amend will reuse the existing user if not specified, but the obsolete
@@ -235,7 +235,8 b' def addremove(ui, repo, *pats, **opts):'
235 raise util.Abort(_('similarity must be a number'))
235 raise util.Abort(_('similarity must be a number'))
236 if sim < 0 or sim > 100:
236 if sim < 0 or sim > 100:
237 raise util.Abort(_('similarity must be between 0 and 100'))
237 raise util.Abort(_('similarity must be between 0 and 100'))
238 return scmutil.addremove(repo, pats, opts, similarity=sim / 100.0)
238 matcher = scmutil.match(repo[None], pats, opts)
239 return scmutil.addremove(repo, matcher, opts, similarity=sim / 100.0)
239
240
240 @command('^annotate|blame',
241 @command('^annotate|blame',
241 [('r', 'rev', '', _('annotate the specified revision'), _('REV')),
242 [('r', 'rev', '', _('annotate the specified revision'), _('REV')),
@@ -713,13 +713,13 b' def matchfiles(repo, files):'
713 '''Return a matcher that will efficiently match exactly these files.'''
713 '''Return a matcher that will efficiently match exactly these files.'''
714 return matchmod.exact(repo.root, repo.getcwd(), files)
714 return matchmod.exact(repo.root, repo.getcwd(), files)
715
715
716 def addremove(repo, pats=[], opts={}, dry_run=None, similarity=None):
716 def addremove(repo, matcher, opts={}, dry_run=None, similarity=None):
717 m = matcher
717 if dry_run is None:
718 if dry_run is None:
718 dry_run = opts.get('dry_run')
719 dry_run = opts.get('dry_run')
719 if similarity is None:
720 if similarity is None:
720 similarity = float(opts.get('similarity') or 0)
721 similarity = float(opts.get('similarity') or 0)
721 # we'd use status here, except handling of symlinks and ignore is tricky
722
722 m = match(repo[None], pats, opts)
723 rejected = []
723 rejected = []
724 m.bad = lambda x, y: rejected.append(x)
724 m.bad = lambda x, y: rejected.append(x)
725
725
General Comments 0
You need to be logged in to leave comments. Login now