##// 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 94 try:
95 95 oldquiet = repo.ui.quiet
96 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 99 finally:
99 100 repo.ui.quiet = oldquiet
100 101 fm.end()
@@ -73,7 +73,7 b' def restorematchandpatsfn():'
73 73 scmutil.matchandpats = getattr(scmutil.matchandpats, 'oldmatchandpats',
74 74 scmutil.matchandpats)
75 75
76 def addlargefiles(ui, repo, *pats, **opts):
76 def addlargefiles(ui, repo, matcher, **opts):
77 77 large = opts.pop('large', None)
78 78 lfsize = lfutil.getminsize(
79 79 ui, lfutil.islfilesrepo(repo), opts.pop('lfsize', None))
@@ -85,7 +85,7 b' def addlargefiles(ui, repo, *pats, **opt'
85 85 lfmatcher = match_.match(repo.root, '', list(lfpats))
86 86
87 87 lfnames = []
88 m = scmutil.match(repo[None], pats, opts)
88 m = copy.copy(matcher)
89 89 m.bad = lambda x, y: None
90 90 wctx = repo[None]
91 91 for f in repo.walk(m):
@@ -223,7 +223,8 b' def overrideadd(orig, ui, repo, *pats, *'
223 223 if opts.get('large'):
224 224 raise util.Abort(_('--normal cannot be used with --large'))
225 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 228 installnormalfilesmatchfn(repo[None].manifest())
228 229 result = orig(ui, repo, *pats, **opts)
229 230 restorematchfn()
@@ -1083,10 +1084,10 b' def overridesummary(orig, ui, repo, *pat'
1083 1084 finally:
1084 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 1088 similarity=None):
1088 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 1091 # Get the list of missing largefiles so we can remove them
1091 1092 lfdirstate = lfutil.openlfdirstate(repo.ui, repo)
1092 1093 unsure, s = lfdirstate.status(match_.always(repo.root, repo.getcwd()), [],
@@ -1101,14 +1102,12 b' def scmutiladdremove(orig, repo, pats=[]'
1101 1102 removelargefiles(repo.ui, repo, True, *m, **opts)
1102 1103 # Call into the normal add code, and any files that *should* be added as
1103 1104 # largefiles will be
1104 addlargefiles(repo.ui, repo, *pats, **opts)
1105 addlargefiles(repo.ui, repo, matcher, **opts)
1105 1106 # Now that we've handled largefiles, hand off to the original addremove
1106 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 installnormalfilesmatchfn(repo[None].manifest())
1109 result = orig(repo, pats, opts, dry_run, similarity)
1110 restorematchfn()
1111 return result
1108 # largefiles by passing a matcher that will ignore them.
1109 matcher = composenormalfilematcher(matcher, repo[None].manifest())
1110 return orig(repo, matcher, opts, dry_run, similarity)
1112 1111
1113 1112 # Calling purge with --all will cause the largefiles to be deleted.
1114 1113 # Override repo.status to prevent this from happening.
@@ -2197,14 +2197,14 b' def commit(ui, repo, commitfunc, pats, o'
2197 2197 if date:
2198 2198 opts['date'] = util.parsedate(date)
2199 2199 message = logmessage(ui, opts)
2200 matcher = scmutil.match(repo[None], pats, opts)
2200 2201
2201 2202 # extract addremove carefully -- this function can be called from a command
2202 2203 # that doesn't support addremove
2203 2204 if opts.get('addremove'):
2204 scmutil.addremove(repo, pats, opts)
2205
2206 return commitfunc(ui, repo, message,
2207 scmutil.match(repo[None], pats, opts), opts)
2205 scmutil.addremove(repo, matcher, opts)
2206
2207 return commitfunc(ui, repo, message, matcher, opts)
2208 2208
2209 2209 def amend(ui, repo, commitfunc, old, extra, pats, opts):
2210 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 235 raise util.Abort(_('similarity must be a number'))
236 236 if sim < 0 or sim > 100:
237 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 241 @command('^annotate|blame',
241 242 [('r', 'rev', '', _('annotate the specified revision'), _('REV')),
@@ -713,13 +713,13 b' def matchfiles(repo, files):'
713 713 '''Return a matcher that will efficiently match exactly these files.'''
714 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 718 if dry_run is None:
718 719 dry_run = opts.get('dry_run')
719 720 if similarity is None:
720 721 similarity = float(opts.get('similarity') or 0)
721 # we'd use status here, except handling of symlinks and ignore is tricky
722 m = match(repo[None], pats, opts)
722
723 723 rejected = []
724 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