This make the code a bit simpler and clearer.
(This is an opportunity improvement while looking at something next to that.)
pulkit |
hg-reviewers |
This make the code a bit simpler and clearer.
(This is an opportunity improvement while looking at something next to that.)
Automatic diff as part of commit; lint not applicable. |
Automatic diff as part of commit; unit tests not applicable. |
Path | Packages | |||
---|---|---|---|---|
M | mercurial/transaction.py (12 lines) |
Status | Author | Revision | |
---|---|---|---|
Closed | marmoute | ||
Closed | marmoute | ||
Closed | marmoute | ||
Closed | marmoute | ||
Closed | marmoute | ||
Closed | marmoute | ||
Closed | marmoute | ||
Closed | marmoute | ||
Closed | marmoute | ||
Closed | marmoute | ||
Closed | marmoute | ||
Closed | marmoute | ||
Closed | marmoute | ||
Closed | marmoute | ||
Closed | marmoute | ||
Closed | marmoute | ||
Closed | marmoute | ||
Closed | marmoute | ||
Abandoned | marmoute | ||
Closed | marmoute | ||
Closed | marmoute | ||
Closed | marmoute | ||
Closed | marmoute | ||
Closed | marmoute | ||
Closed | marmoute | ||
Closed | marmoute |
_(b"(failure reason: %s)\n") % stringutil.forcebytestr(exc) | _(b"(failure reason: %s)\n") % stringutil.forcebytestr(exc) | ||||
) | ) | ||||
finally: | finally: | ||||
self._journal = None | self._journal = None | ||||
self._releasefn(self, False) # notify failure of transaction | self._releasefn(self, False) # notify failure of transaction | ||||
self._releasefn = None # Help prevent cycles. | self._releasefn = None # Help prevent cycles. | ||||
BAD_VERSION_MSG = _( | |||||
b"journal was created by a different version of Mercurial\n" | |||||
) | |||||
def rollback(opener, vfsmap, file, report, checkambigfiles=None): | def rollback(opener, vfsmap, file, report, checkambigfiles=None): | ||||
"""Rolls back the transaction contained in the given file | """Rolls back the transaction contained in the given file | ||||
Reads the entries in the specified file, and the corresponding | Reads the entries in the specified file, and the corresponding | ||||
'*.backupfiles' file, to recover from an incomplete transaction. | '*.backupfiles' file, to recover from an incomplete transaction. | ||||
* `file`: a file containing a list of entries, specifying where | * `file`: a file containing a list of entries, specifying where | ||||
to truncate each file. The file should contain a list of | to truncate each file. The file should contain a list of | ||||
if ver == (b'%d' % version): | if ver == (b'%d' % version): | ||||
for line in lines[1:]: | for line in lines[1:]: | ||||
if line: | if line: | ||||
# Shave off the trailing newline | # Shave off the trailing newline | ||||
line = line[:-1] | line = line[:-1] | ||||
l, f, b, c = line.split(b'\0') | l, f, b, c = line.split(b'\0') | ||||
backupentries.append((l, f, b, bool(c))) | backupentries.append((l, f, b, bool(c))) | ||||
else: | else: | ||||
report( | report(BAD_VERSION_MSG) | ||||
_( | |||||
b"journal was created by a different version of " | |||||
b"Mercurial\n" | |||||
) | |||||
) | |||||
_playback( | _playback( | ||||
file, | file, | ||||
report, | report, | ||||
opener, | opener, | ||||
vfsmap, | vfsmap, | ||||
entries, | entries, | ||||
backupentries, | backupentries, | ||||
checkambigfiles=checkambigfiles, | checkambigfiles=checkambigfiles, | ||||
) | ) |