Mercurial > hg
comparison hgext/largefiles/overrides.py @ 43583:73e6d3346e4f
largefiles: move lfstatus context manager to lfutil
Differential Revision: https://phab.mercurial-scm.org/D7139
author | Martin von Zweigbergk <martinvonz@google.com> |
---|---|
date | Fri, 18 Oct 2019 17:46:37 -0700 |
parents | 9f70512ae2cf |
children | 84a0102c05c7 |
comparison
equal
deleted
inserted
replaced
43582:ae5e39512ca0 | 43583:73e6d3346e4f |
---|---|
7 # GNU General Public License version 2 or any later version. | 7 # GNU General Public License version 2 or any later version. |
8 | 8 |
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 | |
13 import copy | 12 import copy |
14 import os | 13 import os |
15 | 14 |
16 from mercurial.i18n import _ | 15 from mercurial.i18n import _ |
17 | 16 |
47 lfutil, | 46 lfutil, |
48 storefactory, | 47 storefactory, |
49 ) | 48 ) |
50 | 49 |
51 eh = exthelper.exthelper() | 50 eh = exthelper.exthelper() |
51 | |
52 lfstatus = lfutil.lfstatus | |
52 | 53 |
53 # -- Utility functions: commonly/repeatedly needed functionality --------------- | 54 # -- Utility functions: commonly/repeatedly needed functionality --------------- |
54 | 55 |
55 | 56 |
56 def composelargefilematcher(match, manifest): | 57 def composelargefilematcher(match, manifest): |
154 if f in m.files() | 155 if f in m.files() |
155 ] | 156 ] |
156 | 157 |
157 added = [f for f in lfnames if f not in bad] | 158 added = [f for f in lfnames if f not in bad] |
158 return added, bad | 159 return added, bad |
159 | |
160 | |
161 @contextlib.contextmanager | |
162 def lfstatus(repo): | |
163 oldvalue = getattr(repo, 'lfstatus', False) | |
164 repo.lfstatus = True | |
165 try: | |
166 yield | |
167 finally: | |
168 repo.lfstatus = oldvalue | |
169 | 160 |
170 | 161 |
171 def removelargefiles(ui, repo, isaddremove, matcher, uipathfn, dryrun, **opts): | 162 def removelargefiles(ui, repo, isaddremove, matcher, uipathfn, dryrun, **opts): |
172 after = opts.get('after') | 163 after = opts.get('after') |
173 m = composelargefilematcher(matcher, repo[None].manifest()) | 164 m = composelargefilematcher(matcher, repo[None].manifest()) |