Patchwork [1,of,2] largefiles: enable subrepo support for forget

login
register
mail settings
Submitter Matt Harbison
Date Jan. 14, 2015, 2:11 a.m.
Message ID <9e24ea4fa4d77dc77375.1421201483@Envy>
Download mbox | patch
Permalink /patch/7448/
State Accepted
Commit 2b79d124a12fb911cf9aff61232be3af3b174527
Headers show

Comments

Matt Harbison - Jan. 14, 2015, 2:11 a.m.
# HG changeset patch
# User Matt Harbison <matt_harbison@yahoo.com>
# Date 1421036451 18000
#      Sun Jan 11 23:20:51 2015 -0500
# Node ID 9e24ea4fa4d77dc77375467a1a8263d5d7e1f4d3
# Parent  b2358bc1407c19007b0e7852262f61d5fe7a8f83
largefiles: enable subrepo support for forget

Patch

diff --git a/hgext/largefiles/overrides.py b/hgext/largefiles/overrides.py
--- a/hgext/largefiles/overrides.py
+++ b/hgext/largefiles/overrides.py
@@ -972,12 +972,10 @@ 
     if s.modified or s.added or s.removed or s.deleted:
         raise util.Abort(_('uncommitted changes'))
 
-def overrideforget(orig, ui, repo, *pats, **opts):
-    installnormalfilesmatchfn(repo[None].manifest())
-    result = orig(ui, repo, *pats, **opts)
-    restorematchfn()
-    m = composelargefilematcher(scmutil.match(repo[None], pats, opts),
-                                repo[None].manifest())
+def cmdutilforget(orig, ui, repo, match, prefix, explicitonly):
+    normalmatcher = composenormalfilematcher(match, repo[None].manifest())
+    bad, forgot = orig(ui, repo, normalmatcher, prefix, explicitonly)
+    m = composelargefilematcher(match, repo[None].manifest())
 
     try:
         repo.lfstatus = True
@@ -992,7 +990,7 @@ 
                 repo.wvfs.isdir(lfutil.standin(f)):
             ui.warn(_('not removing %s: file is already untracked\n')
                     % m.rel(f))
-            result = 1
+            bad.append(f)
 
     for f in forget:
         if ui.verbose or not m.exact(f):
@@ -1012,11 +1010,13 @@ 
         standins = [lfutil.standin(f) for f in forget]
         for f in standins:
             util.unlinkpath(repo.wjoin(f), ignoremissing=True)
-        repo[None].forget(standins)
+        rejected = repo[None].forget(standins)
     finally:
         wlock.release()
 
-    return result
+    bad.extend(f for f in rejected if f in m.files())
+    forgot.extend(f for f in forget if f not in rejected)
+    return bad, forgot
 
 def _getoutgoings(repo, other, missing, addfunc):
     """get pairs of filename and largefile hash in outgoing revisions
diff --git a/hgext/largefiles/uisetup.py b/hgext/largefiles/uisetup.py
--- a/hgext/largefiles/uisetup.py
+++ b/hgext/largefiles/uisetup.py
@@ -34,8 +34,7 @@ 
     entry = extensions.wrapfunction(scmutil, 'addremove',
                                     overrides.scmutiladdremove)
     extensions.wrapfunction(cmdutil, 'remove', overrides.cmdutilremove)
-    entry = extensions.wrapcommand(commands.table, 'forget',
-                                   overrides.overrideforget)
+    extensions.wrapfunction(cmdutil, 'forget', overrides.cmdutilforget)
 
     # Subrepos call status function
     entry = extensions.wrapcommand(commands.table, 'status',
diff --git a/tests/test-subrepo-deep-nested-change.t b/tests/test-subrepo-deep-nested-change.t
--- a/tests/test-subrepo-deep-nested-change.t
+++ b/tests/test-subrepo-deep-nested-change.t
@@ -323,4 +323,25 @@ 
   $ hg --config extensions.largefiles= archive -S -I 'sub/sub2/.hglf/large.bin' ../archive_lf
   $ find ../archive_lf 2> /dev/null | sort
 
+  $ cat >> $HGRCPATH <<EOF
+  > [extensions]
+  > largefiles=
+  > EOF
+
+Test forget through a deep subrepo with the largefiles extension, both a
+largefile and a normal file.  Then a largefile that hasn't been committed yet.
+  $ touch sub1/sub2/untracked.txt
+  $ hg forget sub1/sub2/large.bin sub1/sub2/test.txt sub1/sub2/untracked.txt
+  not removing sub1/sub2/untracked.txt: file is already untracked (glob)
+  [1]
+  $ hg add -v --large -R sub1/sub2 sub1/sub2/untracked.txt
+  adding sub1/sub2/untracked.txt as a largefile (glob)
+  $ hg forget -v sub1/sub2/untracked.txt
+  removing sub1/sub2/untracked.txt (glob)
+  $ hg status -S
+  R sub1/sub2/large.bin
+  R sub1/sub2/test.txt
+  ? foo/bar/abc
+  ? sub1/sub2/untracked.txt
+
   $ cd ..