##// END OF EJS Templates
transaction: move the restoration of backup file in a small closure...
marmoute -
r51235:86dc9e09 stable
parent child Browse files
Show More
@@ -105,6 +105,19 b' def _playback('
105 unlink=True,
105 unlink=True,
106 checkambigfiles=None,
106 checkambigfiles=None,
107 ):
107 ):
108 backupfiles = []
109
110 def restore_one_backup(vfs, f, b, checkambig):
111 filepath = vfs.join(f)
112 backuppath = vfs.join(b)
113 try:
114 util.copyfile(backuppath, filepath, checkambig=checkambig)
115 backupfiles.append((vfs, b))
116 except IOError as exc:
117 e_msg = stringutil.forcebytestr(exc)
118 report(_(b"failed to recover %s (%s)\n") % (f, e_msg))
119 raise
120
108 for f, o in sorted(dict(entries).items()):
121 for f, o in sorted(dict(entries).items()):
109 if o or not unlink:
122 if o or not unlink:
110 checkambig = checkambigfiles and (f, b'') in checkambigfiles
123 checkambig = checkambigfiles and (f, b'') in checkambigfiles
@@ -129,23 +142,14 b' def _playback('
129 except FileNotFoundError:
142 except FileNotFoundError:
130 pass
143 pass
131
144
132 backupfiles = []
133 for l, f, b, c in backupentries:
145 for l, f, b, c in backupentries:
134 if l not in vfsmap and c:
146 if l not in vfsmap and c:
135 report(b"couldn't handle %s: unknown cache location %s\n" % (b, l))
147 report(b"couldn't handle %s: unknown cache location %s\n" % (b, l))
136 vfs = vfsmap[l]
148 vfs = vfsmap[l]
137 try:
149 try:
150 checkambig = checkambigfiles and (f, l) in checkambigfiles
138 if f and b:
151 if f and b:
139 filepath = vfs.join(f)
152 restore_one_backup(vfs, f, b, checkambig)
140 backuppath = vfs.join(b)
141 checkambig = checkambigfiles and (f, l) in checkambigfiles
142 try:
143 util.copyfile(backuppath, filepath, checkambig=checkambig)
144 backupfiles.append((vfs, b))
145 except IOError as exc:
146 e_msg = stringutil.forcebytestr(exc)
147 report(_(b"failed to recover %s (%s)\n") % (f, e_msg))
148 raise
149 else:
153 else:
150 target = f or b
154 target = f or b
151 try:
155 try:
General Comments 0
You need to be logged in to leave comments. Login now