diff hgext/largefiles/overrides.py @ 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 0cb34b3991f8
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"