Mercurial > hg
comparison mercurial/repair.py @ 27873:60ea60fea5f3
with: use context manager for transaction in strip
author | Bryan O'Sullivan <bryano@fb.com> |
---|---|
date | Fri, 15 Jan 2016 13:14:49 -0800 |
parents | f1c316fd91f9 |
children | add2ba16430e |
comparison
equal
deleted
inserted
replaced
27872:a54afc4475d7 | 27873:60ea60fea5f3 |
---|---|
158 if curtr is not None: | 158 if curtr is not None: |
159 del curtr # avoid carrying reference to transaction for nothing | 159 del curtr # avoid carrying reference to transaction for nothing |
160 msg = _('programming error: cannot strip from inside a transaction') | 160 msg = _('programming error: cannot strip from inside a transaction') |
161 raise error.Abort(msg, hint=_('contact your extension maintainer')) | 161 raise error.Abort(msg, hint=_('contact your extension maintainer')) |
162 | 162 |
163 tr = repo.transaction("strip") | |
164 offset = len(tr.entries) | |
165 | |
166 try: | 163 try: |
167 tr.startgroup() | 164 with repo.transaction("strip") as tr: |
168 cl.strip(striprev, tr) | 165 offset = len(tr.entries) |
169 mfst.strip(striprev, tr) | 166 |
170 for fn in files: | 167 tr.startgroup() |
171 repo.file(fn).strip(striprev, tr) | 168 cl.strip(striprev, tr) |
172 tr.endgroup() | 169 mfst.strip(striprev, tr) |
173 | 170 for fn in files: |
174 try: | 171 repo.file(fn).strip(striprev, tr) |
172 tr.endgroup() | |
173 | |
175 for i in xrange(offset, len(tr.entries)): | 174 for i in xrange(offset, len(tr.entries)): |
176 file, troffset, ignore = tr.entries[i] | 175 file, troffset, ignore = tr.entries[i] |
177 repo.svfs(file, 'a').truncate(troffset) | 176 repo.svfs(file, 'a').truncate(troffset) |
178 if troffset == 0: | 177 if troffset == 0: |
179 repo.store.markremoved(file) | 178 repo.store.markremoved(file) |
180 tr.close() | |
181 finally: | |
182 tr.release() | |
183 | 179 |
184 if saveheads or savebases: | 180 if saveheads or savebases: |
185 ui.note(_("adding branch\n")) | 181 ui.note(_("adding branch\n")) |
186 f = vfs.open(chgrpfile, "rb") | 182 f = vfs.open(chgrpfile, "rb") |
187 gen = exchange.readbundle(ui, f, chgrpfile, vfs) | 183 gen = exchange.readbundle(ui, f, chgrpfile, vfs) |