Details
Details
- Reviewers
pulkit - Group Reviewers
hg-reviewers - Commits
- rHG99b881195abf: largefiles: use context manager for wlock in repo.status() override
Diff Detail
Diff Detail
- Repository
- rHG Mercurial
- Lint
Lint Skipped - Unit
Unit Tests Skipped
( )
| pulkit |
| hg-reviewers |
| Lint Skipped |
| Unit Tests Skipped |
| Path | Packages | |||
|---|---|---|---|---|
| M | hgext/largefiles/reposetup.py (22 lines) |
| Commit | Parents | Author | Summary | Date |
|---|---|---|---|---|
| 204b81d83935 | bddcc8c56357 | Martin von Zweigbergk | Oct 19 2019, 12:36 AM |
| Status | Author | Revision | |
|---|---|---|---|
| Abandoned | martinvonz | ||
| Abandoned | martinvonz | ||
| Abandoned | martinvonz | ||
| Abandoned | martinvonz | ||
| Closed | martinvonz | ||
| Closed | martinvonz | ||
| Closed | martinvonz | ||
| Closed | martinvonz | ||
| Closed | martinvonz | ||
| Closed | martinvonz |
| from mercurial.i18n import _ | from mercurial.i18n import _ | ||||
| from mercurial import ( | from mercurial import ( | ||||
| error, | error, | ||||
| localrepo, | localrepo, | ||||
| match as matchmod, | match as matchmod, | ||||
| scmutil, | scmutil, | ||||
| util, | |||||
| ) | ) | ||||
| from . import ( | from . import ( | ||||
| lfcommands, | lfcommands, | ||||
| lfutil, | lfutil, | ||||
| ) | ) | ||||
| ctx1 = self[node1] | ctx1 = self[node1] | ||||
| ctx2 = self[node2] | ctx2 = self[node2] | ||||
| working = ctx2.rev() is None | working = ctx2.rev() is None | ||||
| parentworking = working and ctx1 == self[b'.'] | parentworking = working and ctx1 == self[b'.'] | ||||
| if match is None: | if match is None: | ||||
| match = matchmod.always() | match = matchmod.always() | ||||
| wlock = None | |||||
| try: | |||||
| try: | try: | ||||
| # updating the dirstate is optional | # updating the dirstate is optional | ||||
| # so we don't wait on the lock | # so we don't wait on the lock | ||||
| wlock = self.wlock(False) | wlock = self.wlock(False) | ||||
| gotlock = True | |||||
| except error.LockError: | except error.LockError: | ||||
| pass | wlock = util.nullcontextmanager() | ||||
| gotlock = False | |||||
| with wlock: | |||||
| # First check if paths or patterns were specified on the | # First check if paths or patterns were specified on the | ||||
| # command line. If there were, and they don't match any | # command line. If there were, and they don't match any | ||||
| # largefiles, we should just bail here and let super | # largefiles, we should just bail here and let super | ||||
| # handle it -- thus gaining a big performance boost. | # handle it -- thus gaining a big performance boost. | ||||
| lfdirstate = lfutil.openlfdirstate(ui, self) | lfdirstate = lfutil.openlfdirstate(ui, self) | ||||
| if not match.always(): | if not match.always(): | ||||
| for f in lfdirstate: | for f in lfdirstate: | ||||
| for (list1, list2) in zip(normals, lfstatus) | for (list1, list2) in zip(normals, lfstatus) | ||||
| ] | ] | ||||
| else: # not against working directory | else: # not against working directory | ||||
| result = [ | result = [ | ||||
| [lfutil.splitstandin(f) or f for f in items] | [lfutil.splitstandin(f) or f for f in items] | ||||
| for items in result | for items in result | ||||
| ] | ] | ||||
| if wlock: | if gotlock: | ||||
| lfdirstate.write() | lfdirstate.write() | ||||
| finally: | |||||
| if wlock: | |||||
| wlock.release() | |||||
| self.lfstatus = True | self.lfstatus = True | ||||
| return scmutil.status(*result) | return scmutil.status(*result) | ||||
| def commitctx(self, ctx, *args, **kwargs): | def commitctx(self, ctx, *args, **kwargs): | ||||
| node = super(lfilesrepo, self).commitctx(ctx, *args, **kwargs) | node = super(lfilesrepo, self).commitctx(ctx, *args, **kwargs) | ||||
| class lfilesctx(ctx.__class__): | class lfilesctx(ctx.__class__): | ||||
| def markcommitted(self, node): | def markcommitted(self, node): | ||||