Patchwork D7139: largefiles: move lfstatus context manager to lfutil

login
register
mail settings
Submitter phabricator
Date Oct. 19, 2019, 7:38 a.m.
Message ID <differential-rev-PHID-DREV-wp7vgwlh46qtwk4cfo46-req@mercurial-scm.org>
Download mbox | patch
Permalink /patch/42490/
State Superseded
Headers show

Comments

phabricator - Oct. 19, 2019, 7:38 a.m.
martinvonz created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REPOSITORY
  rHG Mercurial

REVISION DETAIL
  https://phab.mercurial-scm.org/D7139

AFFECTED FILES
  hgext/largefiles/lfutil.py
  hgext/largefiles/overrides.py

CHANGE DETAILS




To: martinvonz, #hg-reviewers
Cc: mercurial-devel

Patch

diff --git a/hgext/largefiles/overrides.py b/hgext/largefiles/overrides.py
--- a/hgext/largefiles/overrides.py
+++ b/hgext/largefiles/overrides.py
@@ -9,7 +9,6 @@ 
 '''Overridden Mercurial commands and functions for the largefiles extension'''
 from __future__ import absolute_import
 
-import contextlib
 import copy
 import os
 
@@ -50,6 +49,8 @@ 
 
 eh = exthelper.exthelper()
 
+lfstatus = lfutil.lfstatus
+
 # -- Utility functions: commonly/repeatedly needed functionality ---------------
 
 
@@ -158,16 +159,6 @@ 
     return added, bad
 
 
-@contextlib.contextmanager
-def lfstatus(repo):
-    oldvalue = getattr(repo, 'lfstatus', False)
-    repo.lfstatus = True
-    try:
-        yield
-    finally:
-        repo.lfstatus = oldvalue
-
-
 def removelargefiles(ui, repo, isaddremove, matcher, uipathfn, dryrun, **opts):
     after = opts.get(r'after')
     m = composelargefilematcher(matcher, repo[None].manifest())
diff --git a/hgext/largefiles/lfutil.py b/hgext/largefiles/lfutil.py
--- a/hgext/largefiles/lfutil.py
+++ b/hgext/largefiles/lfutil.py
@@ -9,6 +9,7 @@ 
 '''largefiles utility code: must not import other modules in this package.'''
 from __future__ import absolute_import
 
+import contextlib
 import copy
 import hashlib
 import os
@@ -39,6 +40,16 @@ 
 # -- Private worker functions ------------------------------------------
 
 
+@contextlib.contextmanager
+def lfstatus(repo):
+    oldvalue = getattr(repo, 'lfstatus', False)
+    repo.lfstatus = True
+    try:
+        yield
+    finally:
+        repo.lfstatus = oldvalue
+
+
 def getminsize(ui, assumelfiles, opt, default=10):
     lfsize = opt
     if not lfsize and assumelfiles: