Details
Details
- Reviewers
- None
- Group Reviewers
hg-reviewers - Commits
- rHG0132221c25cd: localrepo: use context manager for lock and transaction in commitctx()
Diff Detail
Diff Detail
- Repository
- rHG Mercurial
- Lint
Lint Skipped - Unit
Unit Tests Skipped
hg-reviewers |
Lint Skipped |
Unit Tests Skipped |
Path | Packages | |||
---|---|---|---|---|
M | mercurial/localrepo.py (10 lines) |
Commit | Parents | Author | Summary | Date |
---|---|---|---|---|
Martin von Zweigbergk | Sep 24 2018, 5:46 PM |
Status | Author | Revision | |
---|---|---|---|
Closed | martinvonz | ||
Closed | martinvonz | ||
Closed | martinvonz | ||
Closed | martinvonz |
Revision information is passed via the context argument. | Revision information is passed via the context argument. | ||||
ctx.files() should list all files involved in this commit, i.e. | ctx.files() should list all files involved in this commit, i.e. | ||||
modified/added/removed files. On merge, it may be wider than the | modified/added/removed files. On merge, it may be wider than the | ||||
ctx.files() to be committed, since any file nodes derived directly | ctx.files() to be committed, since any file nodes derived directly | ||||
from p1 or p2 are excluded from the committed ctx.files(). | from p1 or p2 are excluded from the committed ctx.files(). | ||||
""" | """ | ||||
tr = None | |||||
p1, p2 = ctx.p1(), ctx.p2() | p1, p2 = ctx.p1(), ctx.p2() | ||||
user = ctx.user() | user = ctx.user() | ||||
lock = self.lock() | with self.lock(), self.transaction("commit") as tr: | ||||
try: | |||||
tr = self.transaction("commit") | |||||
trp = weakref.proxy(tr) | trp = weakref.proxy(tr) | ||||
if ctx.manifestnode(): | if ctx.manifestnode(): | ||||
# reuse an existing manifest revision | # reuse an existing manifest revision | ||||
self.ui.debug('reusing known manifest\n') | self.ui.debug('reusing known manifest\n') | ||||
mn = ctx.manifestnode() | mn = ctx.manifestnode() | ||||
files = ctx.files() | files = ctx.files() | ||||
elif ctx.files(): | elif ctx.files(): | ||||
targetphase = subrepoutil.newcommitphase(self.ui, ctx) | targetphase = subrepoutil.newcommitphase(self.ui, ctx) | ||||
if targetphase: | if targetphase: | ||||
# retract boundary do not alter parent changeset. | # retract boundary do not alter parent changeset. | ||||
# if a parent have higher the resulting phase will | # if a parent have higher the resulting phase will | ||||
# be compliant anyway | # be compliant anyway | ||||
# | # | ||||
# if minimal phase was 0 we don't need to retract anything | # if minimal phase was 0 we don't need to retract anything | ||||
phases.registernew(self, tr, targetphase, [n]) | phases.registernew(self, tr, targetphase, [n]) | ||||
tr.close() | |||||
return n | return n | ||||
finally: | |||||
if tr: | |||||
tr.release() | |||||
lock.release() | |||||
@unfilteredmethod | @unfilteredmethod | ||||
def destroying(self): | def destroying(self): | ||||
'''Inform the repository that nodes are about to be destroyed. | '''Inform the repository that nodes are about to be destroyed. | ||||
Intended for use by strip and rollback, so there's a common | Intended for use by strip and rollback, so there's a common | ||||
place for anything that has to be done before destroying history. | place for anything that has to be done before destroying history. | ||||
This is mostly useful for saving state that is in memory and waiting | This is mostly useful for saving state that is in memory and waiting |