##// END OF EJS Templates
Handle locking exceptions if streaming clone can't lock the repo. (Issue324)
Thomas Arendsen Hein -
r3687:d5dd0a2a default
parent child Browse files
Show More
@@ -1825,8 +1825,12 b' class localrepository(repo.repository):'
1825 1825 except ValueError:
1826 1826 raise util.UnexpectedOutput(
1827 1827 _('Unexpected response from remote server:'), l)
1828 if resp != 0:
1828 if resp == 1:
1829 1829 raise util.Abort(_('operation forbidden by server'))
1830 elif resp == 2:
1831 raise util.Abort(_('locking the remote repository failed'))
1832 elif resp != 0:
1833 raise util.Abort(_('the server sent an unknown error code'))
1830 1834 self.ui.status(_('streaming all changes\n'))
1831 1835 l = fp.readline()
1832 1836 try:
@@ -7,7 +7,7 b''
7 7
8 8 from demandload import demandload
9 9 from i18n import gettext as _
10 demandload(globals(), "os stat util")
10 demandload(globals(), "os stat util lock")
11 11
12 12 # if server supports streaming clone, it advertises "stream"
13 13 # capability with value that is version+flags of repo it is serving.
@@ -65,18 +65,23 b' def stream_out(repo, fileobj):'
65 65 fileobj.write('1\n')
66 66 return
67 67
68 fileobj.write('0\n')
69
70 68 # get consistent snapshot of repo. lock during scan so lock not
71 69 # needed while we stream, and commits can happen.
72 lock = repo.lock()
70 try:
71 repolock = repo.lock()
72 except (lock.LockHeld, lock.LockUnavailable), inst:
73 repo.ui.warn('locking the repository failed: %s\n' % (inst,))
74 fileobj.write('2\n')
75 return
76
77 fileobj.write('0\n')
73 78 repo.ui.debug('scanning\n')
74 79 entries = []
75 80 total_bytes = 0
76 81 for name, size in walkrepo(repo.path):
77 82 entries.append((name, size))
78 83 total_bytes += size
79 lock.release()
84 repolock.release()
80 85
81 86 repo.ui.debug('%d files, %d bytes to transfer\n' %
82 87 (len(entries), total_bytes))
General Comments 0
You need to be logged in to leave comments. Login now