changeset 21884:a858d3de0d32

largefiles: confirm existence of outgoing largefile entities in remote store Before this patch, "hg summary" and "hg outgoing" show and count up all largefiles changed/added in outgoing revisions, even though some of them are already uploaded into remote store. This patch confirms existence of outgoing largefile entities in remote store, to show and count up only really outgoing largefile entities at "hg summary" and "hg outgoing".
author FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
date Mon, 07 Jul 2014 18:45:46 +0900
parents 87aa279f7073
children fe9db58b0b2d
files hgext/largefiles/overrides.py tests/test-largefiles-misc.t tests/test-largefiles.t
diffstat 3 files changed, 53 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/hgext/largefiles/overrides.py	Mon Jul 07 18:45:46 2014 +0900
+++ b/hgext/largefiles/overrides.py	Mon Jul 07 18:45:46 2014 +0900
@@ -992,20 +992,28 @@
 
     return result
 
-def _getoutgoings(repo, missing, addfunc):
+def _getoutgoings(repo, other, missing, addfunc):
     """get pairs of filename and largefile hash in outgoing revisions
     in 'missing'.
 
+    largefiles already existing on 'other' repository are ignored.
+
     'addfunc' is invoked with each unique pairs of filename and
     largefile hash value.
     """
     knowns = set()
+    lfhashes = set()
     def dedup(fn, lfhash):
         k = (fn, lfhash)
         if k not in knowns:
             knowns.add(k)
-            addfunc(fn, lfhash)
+            lfhashes.add(lfhash)
     lfutil.getlfilestoupload(repo, missing, dedup)
+    if lfhashes:
+        lfexists = basestore._openstore(repo, other).exists(lfhashes)
+        for fn, lfhash in knowns:
+            if not lfexists[lfhash]: # lfhash doesn't exist on "other"
+                addfunc(fn, lfhash)
 
 def outgoinghook(ui, repo, other, opts, missing):
     if opts.pop('large', None):
@@ -1027,7 +1035,7 @@
                 lfhashes.add(lfhash)
             def showhashes(fn):
                 pass
-        _getoutgoings(repo, missing, addfunc)
+        _getoutgoings(repo, other, missing, addfunc)
 
         if not toupload:
             ui.status(_('largefiles: no files to upload\n'))
@@ -1058,7 +1066,7 @@
         def addfunc(fn, lfhash):
             toupload.add(fn)
             lfhashes.add(lfhash)
-        _getoutgoings(repo, outgoing.missing, addfunc)
+        _getoutgoings(repo, peer, outgoing.missing, addfunc)
 
         if not toupload:
             # i18n: column positioning for "hg summary"
--- a/tests/test-largefiles-misc.t	Mon Jul 07 18:45:46 2014 +0900
+++ b/tests/test-largefiles-misc.t	Mon Jul 07 18:45:46 2014 +0900
@@ -589,6 +589,46 @@
       89e6c98d92887913cadf06b2adb97f26cde4849b
   
 
+Pusing revision #1 causes uploading entity 89e6c98d9288, which is
+shared also by largefiles b1, b2 in revision #2 and b in revision #5.
+
+Then, entity 89e6c98d9288 is not treated as "outgoing entity" at "hg
+summary" and "hg outgoing", even though files in outgoing revision #2
+and #5 refer it.
+
+  $ hg -R clone2 push -r 1 -q
+  $ hg -R clone2 summary --large
+  parent: 5:036794ea641c tip
+   #5: refer existing largefile entity again
+  branch: default
+  commit: (clean)
+  update: (current)
+  largefiles: 2 entities for 1 files to upload
+  $ hg -R clone2 outgoing --large -T "{rev}:{node|short}\n"
+  comparing with $TESTTMP/issue3651/src (glob)
+  searching for changes
+  2:6095d0695d70
+  3:7983dce246cc
+  4:233f12ada4ae
+  5:036794ea641c
+  largefiles to upload (2 entities):
+  b
+  
+  $ hg -R clone2 outgoing --large -T "{rev}:{node|short}\n" --debug
+  comparing with $TESTTMP/issue3651/src (glob)
+  query 1; heads
+  searching for changes
+  all remote heads known locally
+  2:6095d0695d70
+  3:7983dce246cc
+  4:233f12ada4ae
+  5:036794ea641c
+  largefiles to upload (2 entities):
+  b
+      13f9ed0898e315bf59dc2973fec52037b6f441a2
+      c801c9cfe94400963fcb683246217d5db77f9a9a
+  
+
   $ cd ..
 
 merge action 'd' for 'local renamed directory to d2/g' which has no filename
--- a/tests/test-largefiles.t	Mon Jul 07 18:45:46 2014 +0900
+++ b/tests/test-largefiles.t	Mon Jul 07 18:45:46 2014 +0900
@@ -680,9 +680,7 @@
   date:        Thu Jan 01 00:00:00 1970 +0000
   summary:     this used to not notice the rm
   
-  largefiles to upload (2 entities):
-  foo
-  large
+  largefiles to upload (1 entities):
   large8
   
   $ cd ../a