Mercurial > hg
comparison hgext/largefiles/overrides.py @ 15598:a77ce45584ef stable
largefiles: fix rename (issue3093)
author | Na'Tosha Bard <natosha@unity3d.com> |
---|---|
date | Wed, 30 Nov 2011 15:11:00 +0100 |
parents | e387e760b207 |
children | 931dc4af0d95 9036c7d106bf |
comparison
equal
deleted
inserted
replaced
15597:bc0778f5619a | 15598:a77ce45584ef |
---|---|
371 | 371 |
372 try: | 372 try: |
373 origcopyfile = util.copyfile | 373 origcopyfile = util.copyfile |
374 copiedfiles = [] | 374 copiedfiles = [] |
375 def override_copyfile(src, dest): | 375 def override_copyfile(src, dest): |
376 if lfutil.shortname in src and lfutil.shortname in dest: | 376 if (lfutil.shortname in src and |
377 dest.startswith(repo.wjoin(lfutil.shortname))): | |
377 destlfile = dest.replace(lfutil.shortname, '') | 378 destlfile = dest.replace(lfutil.shortname, '') |
378 if not opts['force'] and os.path.exists(destlfile): | 379 if not opts['force'] and os.path.exists(destlfile): |
379 raise IOError('', | 380 raise IOError('', |
380 _('destination largefile already exists')) | 381 _('destination largefile already exists')) |
381 copiedfiles.append((src, dest)) | 382 copiedfiles.append((src, dest)) |
386 finally: | 387 finally: |
387 util.copyfile = origcopyfile | 388 util.copyfile = origcopyfile |
388 | 389 |
389 lfdirstate = lfutil.openlfdirstate(ui, repo) | 390 lfdirstate = lfutil.openlfdirstate(ui, repo) |
390 for (src, dest) in copiedfiles: | 391 for (src, dest) in copiedfiles: |
391 if lfutil.shortname in src and lfutil.shortname in dest: | 392 if (lfutil.shortname in src and |
392 srclfile = src.replace(lfutil.shortname, '') | 393 dest.startswith(repo.wjoin(lfutil.shortname))): |
393 destlfile = dest.replace(lfutil.shortname, '') | 394 srclfile = src.replace(repo.wjoin(lfutil.standin('')), '') |
395 destlfile = dest.replace(repo.wjoin(lfutil.standin('')), '') | |
394 destlfiledir = os.path.dirname(destlfile) or '.' | 396 destlfiledir = os.path.dirname(destlfile) or '.' |
395 if not os.path.isdir(destlfiledir): | 397 if not os.path.isdir(destlfiledir): |
396 os.makedirs(destlfiledir) | 398 os.makedirs(destlfiledir) |
397 if rename: | 399 if rename: |
398 os.rename(srclfile, destlfile) | 400 os.rename(repo.wjoin(srclfile), repo.wjoin(destlfile)) |
399 lfdirstate.remove(repo.wjoin(srclfile)) | 401 lfdirstate.remove(srclfile) |
400 else: | 402 else: |
401 util.copyfile(srclfile, destlfile) | 403 util.copyfile(srclfile, destlfile) |
402 lfdirstate.add(repo.wjoin(destlfile)) | 404 lfdirstate.add(destlfile) |
403 lfdirstate.write() | 405 lfdirstate.write() |
404 except util.Abort, e: | 406 except util.Abort, e: |
405 if str(e) != 'no files to copy': | 407 if str(e) != 'no files to copy': |
406 raise e | 408 raise e |
407 else: | 409 else: |