comparison hgext/largefiles/overrides.py @ 23038:3f581bfbb268

largefiles: replace repo._isaddremove hack with a simple function parameter
author Mads Kiilerich <madski@unity3d.com>
date Fri, 03 Oct 2014 00:42:40 +0200
parents 1982bdb7e2cc
children 1350b9170089
comparison
equal deleted inserted replaced
23037:eeaed3d2b004 23038:3f581bfbb268
138 if f in m.files()] 138 if f in m.files()]
139 finally: 139 finally:
140 wlock.release() 140 wlock.release()
141 return bad 141 return bad
142 142
143 def removelargefiles(ui, repo, *pats, **opts): 143 def removelargefiles(ui, repo, isaddremove, *pats, **opts):
144 after = opts.get('after') 144 after = opts.get('after')
145 if not pats and not after: 145 if not pats and not after:
146 raise util.Abort(_('no files specified')) 146 raise util.Abort(_('no files specified'))
147 m = scmutil.match(repo[None], pats, opts) 147 m = scmutil.match(repo[None], pats, opts)
148 try: 148 try:
185 lfdirstate = lfutil.openlfdirstate(ui, repo) 185 lfdirstate = lfutil.openlfdirstate(ui, repo)
186 for f in remove: 186 for f in remove:
187 if not after: 187 if not after:
188 # If this is being called by addremove, notify the user that we 188 # If this is being called by addremove, notify the user that we
189 # are removing the file. 189 # are removing the file.
190 if getattr(repo, "_isaddremove", False): 190 if isaddremove:
191 ui.status(_('removing %s\n') % f) 191 ui.status(_('removing %s\n') % f)
192 util.unlinkpath(repo.wjoin(f), ignoremissing=True) 192 util.unlinkpath(repo.wjoin(f), ignoremissing=True)
193 lfdirstate.remove(f) 193 lfdirstate.remove(f)
194 lfdirstate.write() 194 lfdirstate.write()
195 remove = [lfutil.standin(f) for f in remove] 195 remove = [lfutil.standin(f) for f in remove]
196 # If this is being called by addremove, let the original addremove 196 # If this is being called by addremove, let the original addremove
197 # function handle this. 197 # function handle this.
198 if not getattr(repo, "_isaddremove", False): 198 if not isaddremove:
199 for f in remove: 199 for f in remove:
200 util.unlinkpath(repo.wjoin(f), ignoremissing=True) 200 util.unlinkpath(repo.wjoin(f), ignoremissing=True)
201 repo[None].forget(remove) 201 repo[None].forget(remove)
202 finally: 202 finally:
203 wlock.release() 203 wlock.release()
230 230
231 def overrideremove(orig, ui, repo, *pats, **opts): 231 def overrideremove(orig, ui, repo, *pats, **opts):
232 installnormalfilesmatchfn(repo[None].manifest()) 232 installnormalfilesmatchfn(repo[None].manifest())
233 result = orig(ui, repo, *pats, **opts) 233 result = orig(ui, repo, *pats, **opts)
234 restorematchfn() 234 restorematchfn()
235 return removelargefiles(ui, repo, *pats, **opts) or result 235 return removelargefiles(ui, repo, False, *pats, **opts) or result
236 236
237 def overridestatusfn(orig, repo, rev2, **opts): 237 def overridestatusfn(orig, repo, rev2, **opts):
238 try: 238 try:
239 repo._repo.lfstatus = True 239 repo._repo.lfstatus = True
240 return orig(repo, rev2, **opts) 240 return orig(repo, rev2, **opts)
1116 # to have handled by original addremove. Monkey patching here makes sure 1116 # to have handled by original addremove. Monkey patching here makes sure
1117 # we don't remove the standin in the largefiles code, preventing a very 1117 # we don't remove the standin in the largefiles code, preventing a very
1118 # confused state later. 1118 # confused state later.
1119 if s.deleted: 1119 if s.deleted:
1120 m = [repo.wjoin(f) for f in s.deleted] 1120 m = [repo.wjoin(f) for f in s.deleted]
1121 repo._isaddremove = True 1121 removelargefiles(repo.ui, repo, True, *m, **opts)
1122 removelargefiles(repo.ui, repo, *m, **opts)
1123 repo._isaddremove = False
1124 # Call into the normal add code, and any files that *should* be added as 1122 # Call into the normal add code, and any files that *should* be added as
1125 # largefiles will be 1123 # largefiles will be
1126 addlargefiles(repo.ui, repo, *pats, **opts) 1124 addlargefiles(repo.ui, repo, *pats, **opts)
1127 # Now that we've handled largefiles, hand off to the original addremove 1125 # Now that we've handled largefiles, hand off to the original addremove
1128 # function to take care of the rest. Make sure it doesn't do anything with 1126 # function to take care of the rest. Make sure it doesn't do anything with