Mercurial > public > mercurial-scm > hg
diff hgext/largefiles/lfutil.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 | 0509ae083ec1 |
children | 66c6da0bc7e2 |
line wrap: on
line diff
--- a/hgext/largefiles/lfutil.py Fri Mar 14 21:32:05 2014 -0400 +++ b/hgext/largefiles/lfutil.py Wed Apr 16 00:37:24 2014 +0900 @@ -15,6 +15,7 @@ from mercurial import dirstate, httpconnection, match as match_, util, scmutil from mercurial.i18n import _ +from mercurial import node shortname = '.hglf' shortnameslash = shortname + '/' @@ -365,3 +366,25 @@ if f[0] not in filelist: filelist.append(f[0]) return filelist + +def getlfilestoupload(repo, missing, addfunc): + for n in missing: + parents = [p for p in repo.changelog.parents(n) if p != node.nullid] + ctx = repo[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) + for fn in files: + if isstandin(fn) and fn in ctx: + addfunc(fn, ctx[fn].data().strip())