##// 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 except ValueError:
1825 except ValueError:
1826 raise util.UnexpectedOutput(
1826 raise util.UnexpectedOutput(
1827 _('Unexpected response from remote server:'), l)
1827 _('Unexpected response from remote server:'), l)
1828 if resp != 0:
1828 if resp == 1:
1829 raise util.Abort(_('operation forbidden by server'))
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 self.ui.status(_('streaming all changes\n'))
1834 self.ui.status(_('streaming all changes\n'))
1831 l = fp.readline()
1835 l = fp.readline()
1832 try:
1836 try:
@@ -7,7 +7,7 b''
7
7
8 from demandload import demandload
8 from demandload import demandload
9 from i18n import gettext as _
9 from i18n import gettext as _
10 demandload(globals(), "os stat util")
10 demandload(globals(), "os stat util lock")
11
11
12 # if server supports streaming clone, it advertises "stream"
12 # if server supports streaming clone, it advertises "stream"
13 # capability with value that is version+flags of repo it is serving.
13 # capability with value that is version+flags of repo it is serving.
@@ -65,18 +65,23 b' def stream_out(repo, fileobj):'
65 fileobj.write('1\n')
65 fileobj.write('1\n')
66 return
66 return
67
67
68 fileobj.write('0\n')
69
70 # get consistent snapshot of repo. lock during scan so lock not
68 # get consistent snapshot of repo. lock during scan so lock not
71 # needed while we stream, and commits can happen.
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 repo.ui.debug('scanning\n')
78 repo.ui.debug('scanning\n')
74 entries = []
79 entries = []
75 total_bytes = 0
80 total_bytes = 0
76 for name, size in walkrepo(repo.path):
81 for name, size in walkrepo(repo.path):
77 entries.append((name, size))
82 entries.append((name, size))
78 total_bytes += size
83 total_bytes += size
79 lock.release()
84 repolock.release()
80
85
81 repo.ui.debug('%d files, %d bytes to transfer\n' %
86 repo.ui.debug('%d files, %d bytes to transfer\n' %
82 (len(entries), total_bytes))
87 (len(entries), total_bytes))
General Comments 0
You need to be logged in to leave comments. Login now