[PATCH 4 of 9 RFC] normfn: normalize paths in bundle file in global style
FUJIWARA Katsunori
foozy at lares.dti.ne.jp
Fri May 25 10:00:53 CDT 2012
# HG changeset patch
# User FUJIWARA Katsunori <foozy at lares.dti.ne.jp>
# Date 1337957587 -32400
# Node ID c5352f1484a660a1c17cc7267173fad33e4a29bd
# Parent 4a676979c48890516e28b82505d64f8fe9c710bd
normfn: normalize paths in bundle file in global style
mercurial implementation embeds pathes in on-memory-objects
(e.g. manifest, context, and so on) into bundle as it is.
they are normalized in "local style", so should be normalized in
"global style" to create portable bundle.
diff -r 4a676979c488 -r c5352f1484a6 mercurial/localrepo.py
--- a/mercurial/localrepo.py Fri May 25 23:53:07 2012 +0900
+++ b/mercurial/localrepo.py Fri May 25 23:53:07 2012 +0900
@@ -1895,6 +1895,8 @@
else:
reorder = util.parsebool(reorder)
+ fnfromlocal = getattr(self, 'fnfromlocal', lambda x: x)
+
def gengroup():
# Create a changenode group generator that will call our functions
# back to lookup the owning changenode and collect information.
@@ -1927,7 +1929,7 @@
nodelist = prune(filerevlog, fstate[1])
if nodelist:
count[0] += 1
- yield bundler.fileheader(fname)
+ yield bundler.fileheader(fnfromlocal(fname))
for chunk in filerevlog.group(nodelist, bundler, reorder):
yield chunk
@@ -2002,6 +2004,8 @@
else:
reorder = util.parsebool(reorder)
+ fnfromlocal = getattr(self, 'fnfromlocal', lambda x: x)
+
def gengroup():
'''yield a sequence of changegroup chunks (strings)'''
# construct a list of all changed files
@@ -2026,7 +2030,7 @@
nodelist = gennodelst(filerevlog)
if nodelist:
count[0] += 1
- yield bundler.fileheader(fname)
+ yield bundler.fileheader(fnfromlocal(fname))
for chunk in filerevlog.group(nodelist, bundler, reorder):
yield chunk
yield bundler.close()
@@ -2128,12 +2132,16 @@
pr.total = efiles
source.callback = None
+ fntolocal = getattr(self, 'fntolocal', None)
+ if not fntolocal:
+ fntolocal = lambda x: x
while True:
chunkdata = source.filelogheader()
if not chunkdata:
break
f = chunkdata["filename"]
self.ui.debug("adding %s revisions\n" % f)
+ f = fntolocal(f) # convert normalization style from global to local
pr()
fl = self.file(f)
o = len(fl)
More information about the Mercurial-devel
mailing list