changeset 21052:cde32cb5a565

largefiles: use "outgoinghooks" to avoid redundant outgoing check Before this patch, "hg outgoing" invokes "findcommonoutgoing()" not only in "commands.outgoing()" but also in "overrides.overrideoutgoing()" (via "getoutgoinglfiles()"), when largefiles is enabled. The latter is redundant. This patch uses "outgoinghooks" to avoid redundant outgoing check. Newly introduced function "overrides.outgoinghook()" is registered into "outgoinghooks" to get the result of outgoing check in "commands.outgoing()". It invokes "lfutil.getlfilestoupload()" directly with the result of outgoing check to avoid redundant outgoing check in "getoutgoinglfiles()": "sort()" is needed, because "lfutil.getlfilestoupload()" doesn't sort the result of it. This patch also omits "if toupload is None" ("No remote repo") case, because failure of looking remote repository up should raise exception in "commands.outgoing()" before invocation of "outgoinghooks". Newly added "hg outgoing --large --graph" tests examine "outgoinghooks" invocations in "hg outgoing --graph" code path.
author FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
date Wed, 16 Apr 2014 00:37:24 +0900
parents 1004d3cd65fd
children d384ce982a51
files hgext/largefiles/overrides.py hgext/largefiles/uisetup.py tests/test-largefiles.t
diffstat 3 files changed, 22 insertions(+), 14 deletions(-) [+]
line wrap: on
line diff
--- a/hgext/largefiles/overrides.py	Wed Apr 16 00:37:24 2014 +0900
+++ b/hgext/largefiles/overrides.py	Wed Apr 16 00:37:24 2014 +0900
@@ -1005,23 +1005,19 @@
     lfutil.getlfilestoupload(repo, o, lambda fn, lfhash: toupload.add(fn))
     return sorted(toupload)
 
-def overrideoutgoing(orig, ui, repo, dest=None, **opts):
-    result = orig(ui, repo, dest, **opts)
-
+def outgoinghook(ui, repo, other, opts, missing):
     if opts.pop('large', None):
-        toupload = getoutgoinglfiles(ui, repo, dest, **opts)
-        if toupload is None:
-            ui.status(_('largefiles: No remote repo\n'))
-        elif not toupload:
+        toupload = set()
+        lfutil.getlfilestoupload(repo, missing,
+                                 lambda fn, lfhash: toupload.add(fn))
+        if not toupload:
             ui.status(_('largefiles: no files to upload\n'))
         else:
             ui.status(_('largefiles to upload:\n'))
-            for file in toupload:
+            for file in sorted(toupload):
                 ui.status(lfutil.splitstandin(file) + '\n')
             ui.status('\n')
 
-    return result
-
 def summaryremotehook(ui, repo, opts, changes):
     largeopt = opts.get('large', False)
     if changes is None:
--- a/hgext/largefiles/uisetup.py	Wed Apr 16 00:37:24 2014 +0900
+++ b/hgext/largefiles/uisetup.py	Wed Apr 16 00:37:24 2014 +0900
@@ -65,10 +65,11 @@
     debugstateopt = [('', 'large', None, _('display largefiles dirstate'))]
     entry[1].extend(debugstateopt)
 
-    entry = extensions.wrapcommand(commands.table, 'outgoing',
-        overrides.overrideoutgoing)
+    outgoing = lambda orgfunc, *arg, **kwargs: orgfunc(*arg, **kwargs)
+    entry = extensions.wrapcommand(commands.table, 'outgoing', outgoing)
     outgoingopt = [('', 'large', None, _('display outgoing largefiles'))]
     entry[1].extend(outgoingopt)
+    cmdutil.outgoinghooks.add('largefiles', overrides.outgoinghook)
     entry = extensions.wrapcommand(commands.table, 'summary',
                                    overrides.overridesummary)
     summaryopt = [('', 'large', None, _('display outgoing largefiles'))]
--- a/tests/test-largefiles.t	Wed Apr 16 00:37:24 2014 +0900
+++ b/tests/test-largefiles.t	Wed Apr 16 00:37:24 2014 +0900
@@ -703,7 +703,6 @@
   date:        Thu Jan 01 00:00:00 1970 +0000
   summary:     this used to not notice the rm
   
-  searching for changes
   largefiles to upload:
   foo
   large
@@ -2154,10 +2153,15 @@
   comparing with $TESTTMP/issue3651/src (glob)
   searching for changes
   no changes found
-  searching for changes
   largefiles: no files to upload
   [1]
 
+  $ hg -R clone2 outgoing --large --graph --template "{rev}"
+  comparing with $TESTTMP/issue3651/src (glob)
+  searching for changes
+  no changes found
+  largefiles: no files to upload
+
 check messages when there are files to upload:
 
   $ echo b > clone2/b
@@ -2181,7 +2185,14 @@
   date:        Thu Jan 01 00:00:00 1970 +0000
   summary:     #1
   
+  largefiles to upload:
+  b
+  
+  $ hg -R clone2 outgoing --large --graph --template "{rev}"
+  comparing with $TESTTMP/issue3651/src
   searching for changes
+  @  1
+  
   largefiles to upload:
   b