Mercurial > hg
comparison hgext/largefiles/reposetup.py @ 43585:99b881195abf
largefiles: use context manager for wlock in repo.status() override
Differential Revision: https://phab.mercurial-scm.org/D7141
author | Martin von Zweigbergk <martinvonz@google.com> |
---|---|
date | Fri, 18 Oct 2019 21:36:19 -0700 |
parents | 0371a8c84827 |
children | d77e8800790b |
comparison
equal
deleted
inserted
replaced
43584:a02e4c12ae60 | 43585:99b881195abf |
---|---|
16 from mercurial import ( | 16 from mercurial import ( |
17 error, | 17 error, |
18 localrepo, | 18 localrepo, |
19 match as matchmod, | 19 match as matchmod, |
20 scmutil, | 20 scmutil, |
21 util, | |
21 ) | 22 ) |
22 | 23 |
23 from . import ( | 24 from . import ( |
24 lfcommands, | 25 lfcommands, |
25 lfutil, | 26 lfutil, |
128 parentworking = working and ctx1 == self[b'.'] | 129 parentworking = working and ctx1 == self[b'.'] |
129 | 130 |
130 if match is None: | 131 if match is None: |
131 match = matchmod.always() | 132 match = matchmod.always() |
132 | 133 |
133 wlock = None | |
134 try: | 134 try: |
135 try: | 135 # updating the dirstate is optional |
136 # updating the dirstate is optional | 136 # so we don't wait on the lock |
137 # so we don't wait on the lock | 137 wlock = self.wlock(False) |
138 wlock = self.wlock(False) | 138 gotlock = True |
139 except error.LockError: | 139 except error.LockError: |
140 pass | 140 wlock = util.nullcontextmanager() |
141 gotlock = False | |
142 with wlock: | |
141 | 143 |
142 # First check if paths or patterns were specified on the | 144 # First check if paths or patterns were specified on the |
143 # command line. If there were, and they don't match any | 145 # command line. If there were, and they don't match any |
144 # largefiles, we should just bail here and let super | 146 # largefiles, we should just bail here and let super |
145 # handle it -- thus gaining a big performance boost. | 147 # handle it -- thus gaining a big performance boost. |
306 result = [ | 308 result = [ |
307 [lfutil.splitstandin(f) or f for f in items] | 309 [lfutil.splitstandin(f) or f for f in items] |
308 for items in result | 310 for items in result |
309 ] | 311 ] |
310 | 312 |
311 if wlock: | 313 if gotlock: |
312 lfdirstate.write() | 314 lfdirstate.write() |
313 | |
314 finally: | |
315 if wlock: | |
316 wlock.release() | |
317 | 315 |
318 self.lfstatus = True | 316 self.lfstatus = True |
319 return scmutil.status(*result) | 317 return scmutil.status(*result) |
320 | 318 |
321 def commitctx(self, ctx, *args, **kwargs): | 319 def commitctx(self, ctx, *args, **kwargs): |