Patchwork [4,of,4,RESEND] largefiles: confirm existence of outgoing largefile entities in remote store

login
register
mail settings
Submitter Katsunori FUJIWARA
Date July 8, 2014, 2:40 a.m.
Message ID <54b66b8afb5eb87723ca.1404787226@juju>
Download mbox | patch
Permalink /patch/5130/
State Accepted
Commit a858d3de0d325c23bd3343b23905928648e2480e
Headers show

Comments

Katsunori FUJIWARA - July 8, 2014, 2:40 a.m.
# HG changeset patch
# User FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
# Date 1404726346 -32400
#      Mon Jul 07 18:45:46 2014 +0900
# Node ID 54b66b8afb5eb87723ca81cf67019f4bf132cc03
# Parent  2127aa8952075f9f12ad68c4374c9e0f00cc497d
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".
Matt Mackall - July 16, 2014, 10:13 p.m.
On Tue, 2014-07-08 at 11:40 +0900, FUJIWARA Katsunori wrote:
> # HG changeset patch
> # User FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
> # Date 1404726346 -32400
> #      Mon Jul 07 18:45:46 2014 +0900
> # Node ID 54b66b8afb5eb87723ca81cf67019f4bf132cc03
> # Parent  2127aa8952075f9f12ad68c4374c9e0f00cc497d
> largefiles: confirm existence of outgoing largefile entities in remote store

These are queued for default, thanks.

Patch

diff --git a/hgext/largefiles/overrides.py b/hgext/largefiles/overrides.py
--- a/hgext/largefiles/overrides.py
+++ b/hgext/largefiles/overrides.py
@@ -992,20 +992,28 @@  def overrideforget(orig, ui, repo, *pats
 
     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 @@  def outgoinghook(ui, repo, other, opts, 
                 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 summaryremotehook(ui, repo, opts, ch
         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"
diff --git a/tests/test-largefiles-misc.t b/tests/test-largefiles-misc.t
--- a/tests/test-largefiles-misc.t
+++ b/tests/test-largefiles-misc.t
@@ -589,6 +589,46 @@  check messages when there are files to u
       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
diff --git a/tests/test-largefiles.t b/tests/test-largefiles.t
--- a/tests/test-largefiles.t
+++ b/tests/test-largefiles.t
@@ -680,9 +680,7 @@  Test that outgoing --large works (with r
   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