[PATCH 3 of 8] largefiles: replace repo._isaddremove hack with a simple function parameter

Mads Kiilerich mads at kiilerich.com
Tue Oct 14 22:09:10 CDT 2014


# HG changeset patch
# User Mads Kiilerich <madski at unity3d.com>
# Date 1412289760 -7200
#      Fri Oct 03 00:42:40 2014 +0200
# Node ID 171c081e0a09f34fff89f30609267fc5ad9d8fe3
# Parent  11a264fc876af9214c911d17e99f3ba8d08c171a
largefiles: replace repo._isaddremove hack with a simple function parameter

diff --git a/hgext/largefiles/overrides.py b/hgext/largefiles/overrides.py
--- a/hgext/largefiles/overrides.py
+++ b/hgext/largefiles/overrides.py
@@ -140,7 +140,7 @@ def addlargefiles(ui, repo, *pats, **opt
         wlock.release()
     return bad
 
-def removelargefiles(ui, repo, *pats, **opts):
+def removelargefiles(ui, repo, isaddremove, *pats, **opts):
     after = opts.get('after')
     if not pats and not after:
         raise util.Abort(_('no files specified'))
@@ -187,7 +187,7 @@ def removelargefiles(ui, repo, *pats, **
             if not after:
                 # If this is being called by addremove, notify the user that we
                 # are removing the file.
-                if getattr(repo, "_isaddremove", False):
+                if isaddremove:
                     ui.status(_('removing %s\n') % f)
                 util.unlinkpath(repo.wjoin(f), ignoremissing=True)
             lfdirstate.remove(f)
@@ -195,7 +195,7 @@ def removelargefiles(ui, repo, *pats, **
         remove = [lfutil.standin(f) for f in remove]
         # If this is being called by addremove, let the original addremove
         # function handle this.
-        if not getattr(repo, "_isaddremove", False):
+        if not isaddremove:
             for f in remove:
                 util.unlinkpath(repo.wjoin(f), ignoremissing=True)
         repo[None].forget(remove)
@@ -232,7 +232,7 @@ def overrideremove(orig, ui, repo, *pats
     installnormalfilesmatchfn(repo[None].manifest())
     result = orig(ui, repo, *pats, **opts)
     restorematchfn()
-    return removelargefiles(ui, repo, *pats, **opts) or result
+    return removelargefiles(ui, repo, False, *pats, **opts) or result
 
 def overridestatusfn(orig, repo, rev2, **opts):
     try:
@@ -1118,9 +1118,7 @@ def scmutiladdremove(orig, repo, pats=[]
     # confused state later.
     if s.deleted:
         m = [repo.wjoin(f) for f in s.deleted]
-        repo._isaddremove = True
-        removelargefiles(repo.ui, repo, *m, **opts)
-        repo._isaddremove = False
+        removelargefiles(repo.ui, repo, True, *m, **opts)
     # Call into the normal add code, and any files that *should* be added as
     # largefiles will be
     addlargefiles(repo.ui, repo, *pats, **opts)


More information about the Mercurial-devel mailing list