##// END OF EJS Templates
largefiles: use uipathfn instead of match.{rel,uipath}() (API)...
Martin von Zweigbergk -
r41803:f1640764 default
parent child Browse files
Show More
@@ -78,7 +78,7 b' def composenormalfilematcher(match, mani'
78 m.matchfn = lambda f: notlfile(f) and origmatchfn(f)
78 m.matchfn = lambda f: notlfile(f) and origmatchfn(f)
79 return m
79 return m
80
80
81 def addlargefiles(ui, repo, isaddremove, matcher, **opts):
81 def addlargefiles(ui, repo, isaddremove, matcher, uipathfn, **opts):
82 large = opts.get(r'large')
82 large = opts.get(r'large')
83 lfsize = lfutil.getminsize(
83 lfsize = lfutil.getminsize(
84 ui, lfutil.islfilesrepo(repo), opts.get(r'lfsize'))
84 ui, lfutil.islfilesrepo(repo), opts.get(r'lfsize'))
@@ -99,17 +99,11 b' def addlargefiles(ui, repo, isaddremove,'
99 nfile = f in wctx
99 nfile = f in wctx
100 exists = lfile or nfile
100 exists = lfile or nfile
101
101
102 # addremove in core gets fancy with the name, add doesn't
103 if isaddremove:
104 name = m.uipath(f)
105 else:
106 name = m.rel(f)
107
108 # Don't warn the user when they attempt to add a normal tracked file.
102 # Don't warn the user when they attempt to add a normal tracked file.
109 # The normal add code will do that for us.
103 # The normal add code will do that for us.
110 if exact and exists:
104 if exact and exists:
111 if lfile:
105 if lfile:
112 ui.warn(_('%s already a largefile\n') % name)
106 ui.warn(_('%s already a largefile\n') % uipathfn(f))
113 continue
107 continue
114
108
115 if (exact or not exists) and not lfutil.isstandin(f):
109 if (exact or not exists) and not lfutil.isstandin(f):
@@ -123,7 +117,7 b' def addlargefiles(ui, repo, isaddremove,'
123 if large or abovemin or (lfmatcher and lfmatcher(f)):
117 if large or abovemin or (lfmatcher and lfmatcher(f)):
124 lfnames.append(f)
118 lfnames.append(f)
125 if ui.verbose or not exact:
119 if ui.verbose or not exact:
126 ui.status(_('adding %s as a largefile\n') % name)
120 ui.status(_('adding %s as a largefile\n') % uipathfn(f))
127
121
128 bad = []
122 bad = []
129
123
@@ -150,7 +144,7 b' def addlargefiles(ui, repo, isaddremove,'
150 added = [f for f in lfnames if f not in bad]
144 added = [f for f in lfnames if f not in bad]
151 return added, bad
145 return added, bad
152
146
153 def removelargefiles(ui, repo, isaddremove, matcher, dryrun, **opts):
147 def removelargefiles(ui, repo, isaddremove, matcher, uipathfn, dryrun, **opts):
154 after = opts.get(r'after')
148 after = opts.get(r'after')
155 m = composelargefilematcher(matcher, repo[None].manifest())
149 m = composelargefilematcher(matcher, repo[None].manifest())
156 try:
150 try:
@@ -166,7 +160,7 b' def removelargefiles(ui, repo, isaddremo'
166
160
167 def warn(files, msg):
161 def warn(files, msg):
168 for f in files:
162 for f in files:
169 ui.warn(msg % m.rel(f))
163 ui.warn(msg % uipathfn(f))
170 return int(len(files) > 0)
164 return int(len(files) > 0)
171
165
172 if after:
166 if after:
@@ -186,12 +180,7 b' def removelargefiles(ui, repo, isaddremo'
186 lfdirstate = lfutil.openlfdirstate(ui, repo)
180 lfdirstate = lfutil.openlfdirstate(ui, repo)
187 for f in sorted(remove):
181 for f in sorted(remove):
188 if ui.verbose or not m.exact(f):
182 if ui.verbose or not m.exact(f):
189 # addremove in core gets fancy with the name, remove doesn't
183 ui.status(_('removing %s\n') % uipathfn(f))
190 if isaddremove:
191 name = m.uipath(f)
192 else:
193 name = m.rel(f)
194 ui.status(_('removing %s\n') % name)
195
184
196 if not dryrun:
185 if not dryrun:
197 if not after:
186 if not after:
@@ -240,7 +229,7 b' def cmdutiladd(orig, ui, repo, matcher, '
240 if opts.get(r'normal'):
229 if opts.get(r'normal'):
241 return orig(ui, repo, matcher, prefix, uipathfn, explicitonly, **opts)
230 return orig(ui, repo, matcher, prefix, uipathfn, explicitonly, **opts)
242
231
243 ladded, lbad = addlargefiles(ui, repo, False, matcher, **opts)
232 ladded, lbad = addlargefiles(ui, repo, False, matcher, uipathfn, **opts)
244 normalmatcher = composenormalfilematcher(matcher, repo[None].manifest(),
233 normalmatcher = composenormalfilematcher(matcher, repo[None].manifest(),
245 ladded)
234 ladded)
246 bad = orig(ui, repo, normalmatcher, prefix, uipathfn, explicitonly, **opts)
235 bad = orig(ui, repo, normalmatcher, prefix, uipathfn, explicitonly, **opts)
@@ -254,8 +243,8 b' def cmdutilremove(orig, ui, repo, matche'
254 normalmatcher = composenormalfilematcher(matcher, repo[None].manifest())
243 normalmatcher = composenormalfilematcher(matcher, repo[None].manifest())
255 result = orig(ui, repo, normalmatcher, prefix, uipathfn, after, force,
244 result = orig(ui, repo, normalmatcher, prefix, uipathfn, after, force,
256 subrepos, dryrun)
245 subrepos, dryrun)
257 return removelargefiles(ui, repo, False, matcher, dryrun, after=after,
246 return removelargefiles(ui, repo, False, matcher, uipathfn, dryrun,
258 force=force) or result
247 after=after, force=force) or result
259
248
260 @eh.wrapfunction(subrepo.hgsubrepo, 'status')
249 @eh.wrapfunction(subrepo.hgsubrepo, 'status')
261 def overridestatusfn(orig, repo, rev2, **opts):
250 def overridestatusfn(orig, repo, rev2, **opts):
@@ -1250,11 +1239,11 b' def scmutiladdremove(orig, repo, matcher'
1250 matchfn = m.matchfn
1239 matchfn = m.matchfn
1251 m.matchfn = lambda f: f in s.deleted and matchfn(f)
1240 m.matchfn = lambda f: f in s.deleted and matchfn(f)
1252
1241
1253 removelargefiles(repo.ui, repo, True, m, opts.get('dry_run'),
1242 removelargefiles(repo.ui, repo, True, m, uipathfn, opts.get('dry_run'),
1254 **pycompat.strkwargs(opts))
1243 **pycompat.strkwargs(opts))
1255 # Call into the normal add code, and any files that *should* be added as
1244 # Call into the normal add code, and any files that *should* be added as
1256 # largefiles will be
1245 # largefiles will be
1257 added, bad = addlargefiles(repo.ui, repo, True, matcher,
1246 added, bad = addlargefiles(repo.ui, repo, True, matcher, uipathfn,
1258 **pycompat.strkwargs(opts))
1247 **pycompat.strkwargs(opts))
1259 # Now that we've handled largefiles, hand off to the original addremove
1248 # Now that we've handled largefiles, hand off to the original addremove
1260 # function to take care of the rest. Make sure it doesn't do anything with
1249 # function to take care of the rest. Make sure it doesn't do anything with
General Comments 0
You need to be logged in to leave comments. Login now