Mercurial > public > mercurial-scm > hg
comparison mercurial/cmdutil.py @ 32921:5694311db6ed
amend: use context manager for locking
author | Martin von Zweigbergk <martinvonz@google.com> |
---|---|
date | Mon, 19 Jun 2017 11:21:37 -0700 |
parents | a3a36bcf122e |
children | 74fa8753990b |
comparison
equal
deleted
inserted
replaced
32920:8dbcb66ac160 | 32921:5694311db6ed |
---|---|
28 crecord as crecordmod, | 28 crecord as crecordmod, |
29 encoding, | 29 encoding, |
30 error, | 30 error, |
31 formatter, | 31 formatter, |
32 graphmod, | 32 graphmod, |
33 lock as lockmod, | |
34 match as matchmod, | 33 match as matchmod, |
35 obsolete, | 34 obsolete, |
36 patch, | 35 patch, |
37 pathutil, | 36 pathutil, |
38 phases, | 37 phases, |
2728 | 2727 |
2729 ui.note(_('amending changeset %s\n') % old) | 2728 ui.note(_('amending changeset %s\n') % old) |
2730 base = old.p1() | 2729 base = old.p1() |
2731 createmarkers = obsolete.isenabled(repo, obsolete.createmarkersopt) | 2730 createmarkers = obsolete.isenabled(repo, obsolete.createmarkersopt) |
2732 | 2731 |
2733 wlock = lock = newid = None | 2732 newid = None |
2734 try: | 2733 with repo.wlock(), repo.lock(): |
2735 wlock = repo.wlock() | |
2736 lock = repo.lock() | |
2737 with repo.transaction('amend') as tr: | 2734 with repo.transaction('amend') as tr: |
2738 # See if we got a message from -m or -l, if not, open the editor | 2735 # See if we got a message from -m or -l, if not, open the editor |
2739 # with the message of the changeset to amend | 2736 # with the message of the changeset to amend |
2740 message = logmessage(ui, opts) | 2737 message = logmessage(ui, opts) |
2741 # ensure logfile does not conflict with later enforcement of the | 2738 # ensure logfile does not conflict with later enforcement of the |
2894 # commit | 2891 # commit |
2895 if node: | 2892 if node: |
2896 ui.note(_('stripping intermediate changeset %s\n') % ctx) | 2893 ui.note(_('stripping intermediate changeset %s\n') % ctx) |
2897 ui.note(_('stripping amended changeset %s\n') % old) | 2894 ui.note(_('stripping amended changeset %s\n') % old) |
2898 repair.strip(ui, repo, old.node(), topic='amend-backup') | 2895 repair.strip(ui, repo, old.node(), topic='amend-backup') |
2899 finally: | |
2900 lockmod.release(lock, wlock) | |
2901 return newid | 2896 return newid |
2902 | 2897 |
2903 def commiteditor(repo, ctx, subs, editform=''): | 2898 def commiteditor(repo, ctx, subs, editform=''): |
2904 if ctx.description(): | 2899 if ctx.description(): |
2905 return ctx.description() | 2900 return ctx.description() |