##// END OF EJS Templates
clone: fall back to pull if we can't lock the source repo
mpm@selenic.com -
r1244:937ee88d default
parent child Browse files
Show More
@@ -0,0 +1,20 b''
1 #!/bin/sh
2
3 mkdir a
4 cd a
5 hg init
6 echo foo > b
7 hg add b
8 hg ci -m "b" -d "0 0"
9
10 chmod -w .hg
11
12 cd ..
13
14 hg clone a b
15 cd b
16 hg verify
17
18 cd ..
19
20 chmod +w a/.hg # let test clean up
@@ -0,0 +1,10 b''
1 requesting all changes
2 adding changesets
3 adding manifests
4 adding file changes
5 added 1 changesets with 1 changes to 1 files
6 checking changesets
7 checking manifests
8 crosschecking files in changesets and manifests
9 checking files
10 1 files, 1 changesets, 1 total revisions
@@ -621,15 +621,23 b' def clone(ui, source, dest=None, **opts)'
621 abspath = source
621 abspath = source
622 other = hg.repository(ui, source)
622 other = hg.repository(ui, source)
623
623
624 copy = False
624 if other.dev() != -1:
625 if other.dev() != -1:
625 abspath = os.path.abspath(source)
626 abspath = os.path.abspath(source)
627 copy = True
626
628
627 # we use a lock here because if we race with commit, we can
629 if copy:
628 # end up with extra data in the cloned revlogs that's not
630 try:
629 # pointed to by changesets, thus causing verify to fail
631 # we use a lock here because if we race with commit, we
630 l1 = lock.lock(os.path.join(source, ".hg", "lock"))
632 # can end up with extra data in the cloned revlogs that's
633 # not pointed to by changesets, thus causing verify to
634 # fail
635 l1 = lock.lock(os.path.join(source, ".hg", "lock"))
636 except OSError:
637 copy = False
631
638
632 # and here to avoid premature writing to the target
639 if copy:
640 # we lock here to avoid premature writing to the target
633 os.mkdir(os.path.join(dest, ".hg"))
641 os.mkdir(os.path.join(dest, ".hg"))
634 l2 = lock.lock(os.path.join(dest, ".hg", "lock"))
642 l2 = lock.lock(os.path.join(dest, ".hg", "lock"))
635
643
General Comments 0
You need to be logged in to leave comments. Login now