diff hgext/largefiles/reposetup.py @ 21042:32b3331f18eb

largefiles: centralize the logic to get outgoing largefiles Before this patch, "overrides.getoutgoinglfiles()" (called by "overrideoutgoing()" and "overridesummary()") and "lfilesrepo.push()" implement similar logic to get outgoing largefiles separately. This patch centralizes the logic to get outgoing largefiles in "lfutil.getlfilestoupload()". "lfutil.getlfilestoupload()" takes "addfunc" argument, because each callers need different information (and it is useful for enhancement in the future). - "overrides.getoutgoinglfiles()" needs only filenames - "lfilesrepo.push()" needs only hashes of largefiles
author FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
date Wed, 16 Apr 2014 00:37:24 +0900
parents 81d6dc8c3c63
children 52a5eabf1f2f
line wrap: on
line diff
--- a/hgext/largefiles/reposetup.py	Fri Mar 14 21:32:05 2014 -0400
+++ b/hgext/largefiles/reposetup.py	Wed Apr 16 00:37:24 2014 +0900
@@ -11,7 +11,6 @@
 import os
 
 from mercurial import error, manifest, match as match_, util, discovery
-from mercurial import node as node_
 from mercurial.i18n import _
 from mercurial import localrepo
 
@@ -419,30 +418,8 @@
             if outgoing.missing:
                 toupload = set()
                 o = self.changelog.nodesbetween(outgoing.missing, revs)[0]
-                for n in o:
-                    parents = [p for p in self.changelog.parents(n)
-                               if p != node_.nullid]
-                    ctx = self[n]
-                    files = set(ctx.files())
-                    if len(parents) == 2:
-                        mc = ctx.manifest()
-                        mp1 = ctx.parents()[0].manifest()
-                        mp2 = ctx.parents()[1].manifest()
-                        for f in mp1:
-                            if f not in mc:
-                                files.add(f)
-                        for f in mp2:
-                            if f not in mc:
-                                files.add(f)
-                        for f in mc:
-                            if mc[f] != mp1.get(f, None) or mc[f] != mp2.get(f,
-                                    None):
-                                files.add(f)
-
-                    toupload = toupload.union(
-                        set([ctx[f].data().strip()
-                             for f in files
-                             if lfutil.isstandin(f) and f in ctx]))
+                addfunc = lambda fn, lfhash: toupload.add(lfhash)
+                lfutil.getlfilestoupload(self, o, addfunc)
                 lfcommands.uploadlfiles(ui, self, remote, toupload)
             return super(lfilesrepo, self).push(remote, force=force, revs=revs,
                 newbranch=newbranch)