Show More
@@ -9,6 +9,7 b'' | |||||
9 | '''Overridden Mercurial commands and functions for the largefiles extension''' |
|
9 | '''Overridden Mercurial commands and functions for the largefiles extension''' | |
10 | from __future__ import absolute_import |
|
10 | from __future__ import absolute_import | |
11 |
|
11 | |||
|
12 | import contextlib | |||
12 | import copy |
|
13 | import copy | |
13 | import os |
|
14 | import os | |
14 |
|
15 | |||
@@ -157,14 +158,20 b' def addlargefiles(ui, repo, isaddremove,' | |||||
157 | return added, bad |
|
158 | return added, bad | |
158 |
|
159 | |||
159 |
|
160 | |||
|
161 | @contextlib.contextmanager | |||
|
162 | def lfstatus(repo): | |||
|
163 | repo.lfstatus = True | |||
|
164 | try: | |||
|
165 | yield | |||
|
166 | finally: | |||
|
167 | repo.lfstatus = False | |||
|
168 | ||||
|
169 | ||||
160 | def removelargefiles(ui, repo, isaddremove, matcher, uipathfn, dryrun, **opts): |
|
170 | def removelargefiles(ui, repo, isaddremove, matcher, uipathfn, dryrun, **opts): | |
161 | after = opts.get(r'after') |
|
171 | after = opts.get(r'after') | |
162 | m = composelargefilematcher(matcher, repo[None].manifest()) |
|
172 | m = composelargefilematcher(matcher, repo[None].manifest()) | |
163 | try: |
|
173 | with lfstatus(repo): | |
164 | repo.lfstatus = True |
|
|||
165 | s = repo.status(match=m, clean=not isaddremove) |
|
174 | s = repo.status(match=m, clean=not isaddremove) | |
166 | finally: |
|
|||
167 | repo.lfstatus = False |
|
|||
168 | manifest = repo[None].manifest() |
|
175 | manifest = repo[None].manifest() | |
169 | modified, added, deleted, clean = [ |
|
176 | modified, added, deleted, clean = [ | |
170 | [f for f in list if lfutil.standin(f) in manifest] |
|
177 | [f for f in list if lfutil.standin(f) in manifest] | |
@@ -308,29 +315,20 b' def cmdutilremove(' | |||||
308 |
|
315 | |||
309 | @eh.wrapfunction(subrepo.hgsubrepo, b'status') |
|
316 | @eh.wrapfunction(subrepo.hgsubrepo, b'status') | |
310 | def overridestatusfn(orig, repo, rev2, **opts): |
|
317 | def overridestatusfn(orig, repo, rev2, **opts): | |
311 | try: |
|
318 | with lfstatus(repo._repo): | |
312 | repo._repo.lfstatus = True |
|
|||
313 | return orig(repo, rev2, **opts) |
|
319 | return orig(repo, rev2, **opts) | |
314 | finally: |
|
|||
315 | repo._repo.lfstatus = False |
|
|||
316 |
|
320 | |||
317 |
|
321 | |||
318 | @eh.wrapcommand(b'status') |
|
322 | @eh.wrapcommand(b'status') | |
319 | def overridestatus(orig, ui, repo, *pats, **opts): |
|
323 | def overridestatus(orig, ui, repo, *pats, **opts): | |
320 | try: |
|
324 | with lfstatus(repo): | |
321 | repo.lfstatus = True |
|
|||
322 | return orig(ui, repo, *pats, **opts) |
|
325 | return orig(ui, repo, *pats, **opts) | |
323 | finally: |
|
|||
324 | repo.lfstatus = False |
|
|||
325 |
|
326 | |||
326 |
|
327 | |||
327 | @eh.wrapfunction(subrepo.hgsubrepo, b'dirty') |
|
328 | @eh.wrapfunction(subrepo.hgsubrepo, b'dirty') | |
328 | def overridedirty(orig, repo, ignoreupdate=False, missing=False): |
|
329 | def overridedirty(orig, repo, ignoreupdate=False, missing=False): | |
329 | try: |
|
330 | with lfstatus(repo._repo): | |
330 | repo._repo.lfstatus = True |
|
|||
331 | return orig(repo, ignoreupdate=ignoreupdate, missing=missing) |
|
331 | return orig(repo, ignoreupdate=ignoreupdate, missing=missing) | |
332 | finally: |
|
|||
333 | repo._repo.lfstatus = False |
|
|||
334 |
|
332 | |||
335 |
|
333 | |||
336 | @eh.wrapcommand(b'log') |
|
334 | @eh.wrapcommand(b'log') | |
@@ -1117,22 +1115,14 b' def overriderebase(orig, ui, repo, **opt' | |||||
1117 |
|
1115 | |||
1118 | @eh.wrapcommand(b'archive') |
|
1116 | @eh.wrapcommand(b'archive') | |
1119 | def overridearchivecmd(orig, ui, repo, dest, **opts): |
|
1117 | def overridearchivecmd(orig, ui, repo, dest, **opts): | |
1120 | repo.unfiltered().lfstatus = True |
|
1118 | with lfstatus(repo.unfiltered()): | |
1121 |
|
||||
1122 | try: |
|
|||
1123 | return orig(ui, repo.unfiltered(), dest, **opts) |
|
1119 | return orig(ui, repo.unfiltered(), dest, **opts) | |
1124 | finally: |
|
|||
1125 | repo.unfiltered().lfstatus = False |
|
|||
1126 |
|
1120 | |||
1127 |
|
1121 | |||
1128 | @eh.wrapfunction(webcommands, b'archive') |
|
1122 | @eh.wrapfunction(webcommands, b'archive') | |
1129 | def hgwebarchive(orig, web): |
|
1123 | def hgwebarchive(orig, web): | |
1130 | web.repo.lfstatus = True |
|
1124 | with lfstatus(web.repo): | |
1131 |
|
||||
1132 | try: |
|
|||
1133 | return orig(web) |
|
1125 | return orig(web) | |
1134 | finally: |
|
|||
1135 | web.repo.lfstatus = False |
|
|||
1136 |
|
1126 | |||
1137 |
|
1127 | |||
1138 | @eh.wrapfunction(archival, b'archive') |
|
1128 | @eh.wrapfunction(archival, b'archive') | |
@@ -1286,20 +1276,16 b' def hgsubrepoarchive(orig, repo, archive' | |||||
1286 | @eh.wrapfunction(cmdutil, b'bailifchanged') |
|
1276 | @eh.wrapfunction(cmdutil, b'bailifchanged') | |
1287 | def overridebailifchanged(orig, repo, *args, **kwargs): |
|
1277 | def overridebailifchanged(orig, repo, *args, **kwargs): | |
1288 | orig(repo, *args, **kwargs) |
|
1278 | orig(repo, *args, **kwargs) | |
1289 | repo.lfstatus = True |
|
1279 | with lfstatus(repo): | |
1290 | s = repo.status() |
|
1280 | s = repo.status() | |
1291 | repo.lfstatus = False |
|
|||
1292 | if s.modified or s.added or s.removed or s.deleted: |
|
1281 | if s.modified or s.added or s.removed or s.deleted: | |
1293 | raise error.Abort(_(b'uncommitted changes')) |
|
1282 | raise error.Abort(_(b'uncommitted changes')) | |
1294 |
|
1283 | |||
1295 |
|
1284 | |||
1296 | @eh.wrapfunction(cmdutil, b'postcommitstatus') |
|
1285 | @eh.wrapfunction(cmdutil, b'postcommitstatus') | |
1297 | def postcommitstatus(orig, repo, *args, **kwargs): |
|
1286 | def postcommitstatus(orig, repo, *args, **kwargs): | |
1298 | repo.lfstatus = True |
|
1287 | with lfstatus(repo): | |
1299 | try: |
|
|||
1300 | return orig(repo, *args, **kwargs) |
|
1288 | return orig(repo, *args, **kwargs) | |
1301 | finally: |
|
|||
1302 | repo.lfstatus = False |
|
|||
1303 |
|
1289 | |||
1304 |
|
1290 | |||
1305 | @eh.wrapfunction(cmdutil, b'forget') |
|
1291 | @eh.wrapfunction(cmdutil, b'forget') | |
@@ -1319,11 +1305,8 b' def cmdutilforget(' | |||||
1319 | ) |
|
1305 | ) | |
1320 | m = composelargefilematcher(match, repo[None].manifest()) |
|
1306 | m = composelargefilematcher(match, repo[None].manifest()) | |
1321 |
|
1307 | |||
1322 | try: |
|
1308 | with lfstatus(repo): | |
1323 | repo.lfstatus = True |
|
|||
1324 | s = repo.status(match=m, clean=True) |
|
1309 | s = repo.status(match=m, clean=True) | |
1325 | finally: |
|
|||
1326 | repo.lfstatus = False |
|
|||
1327 | manifest = repo[None].manifest() |
|
1310 | manifest = repo[None].manifest() | |
1328 | forget = sorted(s.modified + s.added + s.deleted + s.clean) |
|
1311 | forget = sorted(s.modified + s.added + s.deleted + s.clean) | |
1329 | forget = [f for f in forget if lfutil.standin(f) in manifest] |
|
1312 | forget = [f for f in forget if lfutil.standin(f) in manifest] | |
@@ -1473,11 +1456,8 b' def summaryremotehook(ui, repo, opts, ch' | |||||
1473 | b'summary', opts=[(b'', b'large', None, _(b'display outgoing largefiles'))] |
|
1456 | b'summary', opts=[(b'', b'large', None, _(b'display outgoing largefiles'))] | |
1474 | ) |
|
1457 | ) | |
1475 | def overridesummary(orig, ui, repo, *pats, **opts): |
|
1458 | def overridesummary(orig, ui, repo, *pats, **opts): | |
1476 | try: |
|
1459 | with lfstatus(repo): | |
1477 | repo.lfstatus = True |
|
|||
1478 | orig(ui, repo, *pats, **opts) |
|
1460 | orig(ui, repo, *pats, **opts) | |
1479 | finally: |
|
|||
1480 | repo.lfstatus = False |
|
|||
1481 |
|
1461 | |||
1482 |
|
1462 | |||
1483 | @eh.wrapfunction(scmutil, b'addremove') |
|
1463 | @eh.wrapfunction(scmutil, b'addremove') |
General Comments 0
You need to be logged in to leave comments.
Login now