Rev 329: Pass in a callable for generating file ids to apply_changes() rather than a in http://people.samba.org/bzr/jelmer/bzr-svn/bzr.dev
Jelmer Vernooij
jelmer at samba.org
Fri Dec 29 19:23:21 GMT 2006
------------------------------------------------------------
revno: 329
revision-id: jelmer at samba.org-20061229192154-oql5chqxnki9xvs1
parent: jelmer at samba.org-20061229184647-pbc050jhf8ls78fk
committer: Jelmer Vernooij <jelmer at samba.org>
branch nick: main
timestamp: Fri 2006-12-29 20:21:54 +0100
message:
Pass in a callable for generating file ids to apply_changes() rather than a
revision id.
modified:
fileids.py fileids.py-20060714013623-u5iiyqqnko11grcf-1
tests/test_fileids.py test_fileids.py-20060622131341-19gyrlgqy8yl2od5-1
=== modified file 'fileids.py'
--- a/fileids.py 2006-12-29 18:46:47 +0000
+++ b/fileids.py 2006-12-29 19:21:54 +0000
@@ -48,7 +48,7 @@
return generate_svn_file_id(uuid, revnum, branch, path)
-def get_local_changes(paths, scheme, uuid, find_children=None):
+def get_local_changes(paths, scheme, uuid, get_children=None):
new_paths = {}
names = paths.keys()
names.sort()
@@ -68,8 +68,8 @@
except NotBranchError:
# Copied from outside of a known branch
# Make it look like the files were added in this revision
- if find_children is not None:
- for c in find_children(data[1], data[2]):
+ if get_children is not None:
+ for c in get_children(data[1], data[2]):
mutter('oops: %r child %r' % (data[1], c))
new_paths[(new_p+"/"+c[len(data[1]):].strip("/")).strip("/")] = (data[0], None, -1)
data = (data[0], None, -1)
@@ -130,7 +130,8 @@
revid = generate_svn_revision_id(uuid, revnum, branch)
- return self._apply_changes(revid, changes, get_children)
+ return self._apply_changes(lambda x: generate_file_id(revid, x),
+ changes, get_children)
def get_map(self, uuid, revnum, branch, pb=None):
"""Make sure the map is up to date until revnum."""
@@ -170,7 +171,8 @@
parent_revs = next_parent_revs
- revmap = self._apply_changes(revid, changes, find_children)
+ revmap = self._apply_changes(lambda x: generate_file_id(revid, x),
+ changes, find_children)
for p in changes:
if changes[p][0] == 'M':
revmap[p] = map[p][0]
@@ -198,7 +200,7 @@
class SimpleFileIdMap(FileIdMap):
@staticmethod
- def _apply_changes(revid, changes, find_children=None):
+ def _apply_changes(new_file_id, changes, find_children=None):
map = {}
sorted_paths = changes.keys()
sorted_paths.sort()
@@ -206,14 +208,14 @@
data = changes[p]
if data[0] in ('A', 'R'):
- map[p] = generate_file_id(revid, p)
+ map[p] = new_file_id(p)
if data[1] is not None:
- mutter('%r:%s copied from %r:%s' % (p, revid, data[1], data[2]))
+ mutter('%r copied from %r:%s' % (p, data[1], data[2]))
if find_children is not None:
for c in find_children(data[1], data[2]):
path = c.replace(data[1], p+"/", 1).replace("//", "/")
- map[path] = generate_file_id(revid, c)
+ map[path] = new_file_id(c)
mutter('added mapping %r -> %r' % (path, map[path]))
return map
=== modified file 'tests/test_fileids.py'
--- a/tests/test_fileids.py 2006-12-29 05:17:51 +0000
+++ b/tests/test_fileids.py 2006-12-29 19:21:54 +0000
@@ -22,7 +22,7 @@
from bzrlib.tests import TestSkipped, TestCase
import format
-from fileids import SimpleFileIdMap
+from fileids import SimpleFileIdMap, generate_file_id
from repository import MAPPING_VERSION
from tests import TestCaseWithSubversionRepository, RENAMES
@@ -153,7 +153,7 @@
revids = mappings.keys()
revids.sort()
for r in revids:
- revmap = SimpleFileIdMap._apply_changes(r, mappings[r], find_children)
+ revmap = SimpleFileIdMap._apply_changes(lambda x: generate_file_id(r, x), mappings[r], find_children)
map.update(dict([(x,(revmap[x],r)) for x in revmap]))
return map
More information about the bazaar-commits
mailing list