603 copyfile = (os.stat(dest).st_dev == other.dev() |
603 copyfile = (os.stat(dest).st_dev == other.dev() |
604 and getattr(os, 'link', None) or shutil.copy2) |
604 and getattr(os, 'link', None) or shutil.copy2) |
605 if copyfile is not shutil.copy2: |
605 if copyfile is not shutil.copy2: |
606 ui.note("cloning by hardlink\n") |
606 ui.note("cloning by hardlink\n") |
607 |
607 |
608 # we use a lock here because because we're not nicely ordered |
608 # we use a lock here because if we race with commit, we can |
609 l = lock.lock(os.path.join(source, ".hg", "lock")) |
609 # end up with extra data in the cloned revlogs that's not |
610 |
610 # pointed to by changesets, thus causing verify to fail |
|
611 l1 = lock.lock(os.path.join(source, ".hg", "lock")) |
|
612 |
|
613 # and here to avoid premature writing to the target |
611 os.mkdir(os.path.join(dest, ".hg")) |
614 os.mkdir(os.path.join(dest, ".hg")) |
|
615 l2 = lock.lock(os.path.join(dest, ".hg", "lock")) |
612 |
616 |
613 files = "data 00manifest.d 00manifest.i 00changelog.d 00changelog.i" |
617 files = "data 00manifest.d 00manifest.i 00changelog.d 00changelog.i" |
614 for f in files.split(): |
618 for f in files.split(): |
615 src = os.path.join(source, ".hg", f) |
619 src = os.path.join(source, ".hg", f) |
616 dst = os.path.join(dest, ".hg", f) |
620 dst = os.path.join(dest, ".hg", f) |