Mercurial > public > mercurial-scm > hg
comparison mercurial/simplemerge.py @ 15057:774da7121fc9
atomictempfile: make close() consistent with other file-like objects.
The usual contract is that close() makes your writes permanent, so
atomictempfile's use of close() to *discard* writes (and rename() to
keep them) is rather unexpected. Thus, change it so close() makes
things permanent and add a new discard() method to throw them away.
discard() is only used internally, in __del__(), to ensure that writes
are discarded when an atomictempfile object goes out of scope.
I audited mercurial.*, hgext.*, and ~80 third-party extensions, and
found no one using the existing semantics of close() to discard
writes, so this should be safe.
author | Greg Ward <greg@gerg.ca> |
---|---|
date | Thu, 25 Aug 2011 20:21:04 -0400 |
parents | 48ec0763afbb |
children | dbdb777502dc |
comparison
equal
deleted
inserted
replaced
15056:8413916df816 | 15057:774da7121fc9 |
---|---|
443 for line in m3.merge_lines(name_a=name_a, name_b=name_b, | 443 for line in m3.merge_lines(name_a=name_a, name_b=name_b, |
444 reprocess=reprocess): | 444 reprocess=reprocess): |
445 out.write(line) | 445 out.write(line) |
446 | 446 |
447 if not opts.get('print'): | 447 if not opts.get('print'): |
448 out.rename() | 448 out.close() |
449 | 449 |
450 if m3.conflicts: | 450 if m3.conflicts: |
451 if not opts.get('quiet'): | 451 if not opts.get('quiet'): |
452 ui.warn(_("warning: conflicts during merge.\n")) | 452 ui.warn(_("warning: conflicts during merge.\n")) |
453 return 1 | 453 return 1 |