Mercurial > public > mercurial-scm > hg-stable
comparison mercurial/cmdutil.py @ 14518:a67e866f46f9
workingctx: eliminate remove function
Inlining it into it's last remaining call place in cmdutil.copy.
Note that cmdutil.copy is called with the wlock already held, so no additional
locking is needed to call util.unlinkpath.
We do not need to wrap the util.unlinkpath call into a try block, because
at that point we already know whether abssrc exists or not -- thanks to the
preceding util.copyfile call. Adding a new local 'srcexists' in cmdutil.copy
for that purpose.
author | Adrian Buehlmann <adrian@cadifra.com> |
---|---|
date | Thu, 02 Jun 2011 00:33:33 +0200 |
parents | 5b48ad1e7f1a |
children | 217b7d83afc3 |
comparison
equal
deleted
inserted
replaced
14517:5a931246afc5 | 14518:a67e866f46f9 |
---|---|
279 os.unlink(target) | 279 os.unlink(target) |
280 targetdir = os.path.dirname(target) or '.' | 280 targetdir = os.path.dirname(target) or '.' |
281 if not os.path.isdir(targetdir): | 281 if not os.path.isdir(targetdir): |
282 os.makedirs(targetdir) | 282 os.makedirs(targetdir) |
283 util.copyfile(src, target) | 283 util.copyfile(src, target) |
284 srcexists = True | |
284 except IOError, inst: | 285 except IOError, inst: |
285 if inst.errno == errno.ENOENT: | 286 if inst.errno == errno.ENOENT: |
286 ui.warn(_('%s: deleted in working copy\n') % relsrc) | 287 ui.warn(_('%s: deleted in working copy\n') % relsrc) |
288 srcexists = False | |
287 else: | 289 else: |
288 ui.warn(_('%s: cannot copy - %s\n') % | 290 ui.warn(_('%s: cannot copy - %s\n') % |
289 (relsrc, inst.strerror)) | 291 (relsrc, inst.strerror)) |
290 return True # report a failure | 292 return True # report a failure |
291 | 293 |
299 | 301 |
300 # fix up dirstate | 302 # fix up dirstate |
301 scmutil.dirstatecopy(ui, repo, wctx, abssrc, abstarget, | 303 scmutil.dirstatecopy(ui, repo, wctx, abssrc, abstarget, |
302 dryrun=dryrun, cwd=cwd) | 304 dryrun=dryrun, cwd=cwd) |
303 if rename and not dryrun: | 305 if rename and not dryrun: |
304 wctx.remove([abssrc], not after) | 306 if not after and srcexists: |
307 util.unlinkpath(repo.wjoin(abssrc)) | |
308 wctx.forget([abssrc]) | |
305 | 309 |
306 # pat: ossep | 310 # pat: ossep |
307 # dest ossep | 311 # dest ossep |
308 # srcs: list of (hgsep, hgsep, ossep, bool) | 312 # srcs: list of (hgsep, hgsep, ossep, bool) |
309 # return: function that takes hgsep and returns ossep | 313 # return: function that takes hgsep and returns ossep |