Details
Details
- Reviewers
- None
- Group Reviewers
hg-reviewers - Commits
- rHGb87a009d1b3b: localrepo: use context manager for locks in commit()
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 | Jan 16 2019, 8:34 PM |
| Status | Author | Revision | |
|---|---|---|---|
| Closed | martinvonz | ||
| Closed | martinvonz | ||
| Closed | martinvonz | ||
| Closed | martinvonz |
| if not match: | if not match: | ||||
| match = matchmod.always(self.root, '') | match = matchmod.always(self.root, '') | ||||
| if not force: | if not force: | ||||
| vdirs = [] | vdirs = [] | ||||
| match.explicitdir = vdirs.append | match.explicitdir = vdirs.append | ||||
| match.bad = fail | match.bad = fail | ||||
| wlock = lock = None | # lock() for recent changelog (see issue4368) | ||||
| try: | with self.wlock(), self.lock(): | ||||
| wlock = self.wlock() | |||||
| lock = self.lock() # for recent changelog (see issue4368) | |||||
| wctx = self[None] | wctx = self[None] | ||||
| merge = len(wctx.parents()) > 1 | merge = len(wctx.parents()) > 1 | ||||
| if not force and merge and not match.always(): | if not force and merge and not match.always(): | ||||
| raise error.Abort(_('cannot partially commit a merge ' | raise error.Abort(_('cannot partially commit a merge ' | ||||
| '(do not specify files or patterns)')) | '(do not specify files or patterns)')) | ||||
| status = self.status(match=match, clean=force) | status = self.status(match=match, clean=force) | ||||
| cctx.markcommitted(ret) | cctx.markcommitted(ret) | ||||
| ms.reset() | ms.reset() | ||||
| except: # re-raises | except: # re-raises | ||||
| if edited: | if edited: | ||||
| self.ui.write( | self.ui.write( | ||||
| _('note: commit message saved in %s\n') % msgfn) | _('note: commit message saved in %s\n') % msgfn) | ||||
| raise | raise | ||||
| finally: | |||||
| lockmod.release(lock, wlock) | |||||
| def commithook(node=hex(ret), parent1=hookp1, parent2=hookp2): | def commithook(node=hex(ret), parent1=hookp1, parent2=hookp2): | ||||
| # hack for command that use a temporary commit (eg: histedit) | # hack for command that use a temporary commit (eg: histedit) | ||||
| # temporary commit got stripped before hook release | # temporary commit got stripped before hook release | ||||
| if self.changelog.hasnode(ret): | if self.changelog.hasnode(ret): | ||||
| self.hook("commit", node=node, parent1=parent1, | self.hook("commit", node=node, parent1=parent1, | ||||
| parent2=parent2) | parent2=parent2) | ||||
| self._afterlock(commithook) | self._afterlock(commithook) | ||||
| return ret | return ret | ||||