Merge lp:bzr-hg into lp:~launchpad-pqm/bzr-hg/devel

Proposed by Aaron Bentley
Status: Merged
Merged at revision: 282
Proposed branch: lp:bzr-hg
Merge into: lp:~launchpad-pqm/bzr-hg/devel
Diff against target: 729 lines (+257/-65)
17 files modified
Makefile (+3/-11)
NEWS (+21/-1)
README (+12/-0)
__init__.py (+48/-7)
branch.py (+19/-10)
commands.py (+55/-0)
fetch.py (+6/-4)
idmap.py (+2/-2)
info.py (+2/-2)
mapping.py (+8/-4)
parsers.py (+8/-5)
repository.py (+6/-1)
setup.py (+1/-1)
tests/__init__.py (+9/-2)
tests/test_dir.py (+42/-0)
tests/test_mapping.py (+1/-1)
tests/test_parsers.py (+14/-14)
To merge this branch: bzr merge lp:bzr-hg
Reviewer Review Type Date Requested Status
Launchpad code reviewers from Canonical Pending
Review via email: mp+31876@code.launchpad.net

Commit message

Update to branch tip for bzr 2.2 compatibility

Description of the change

Update to trunk tip for compatibility with bzr 2.2

To post a comment you must log in.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'Makefile'
--- Makefile 2009-11-01 16:37:38 +0000
+++ Makefile 2010-08-05 19:14:41 +0000
@@ -22,16 +22,8 @@
22 $(SETUP) clean22 $(SETUP) clean
23 rm -f *.so23 rm -f *.so
2424
25TMP_PLUGINS_DIR = $(shell pwd)/.plugins25check:: build-inplace
2626 BZR_PLUGINS_AT=hg@$(shell pwd) $(DEBUGGER) $(PYTHON) $(PYTHON_OPTIONS) $(BZR) $(BZR_OPTIONS) selftest $(TEST_OPTIONS) $(TESTS)
27$(TMP_PLUGINS_DIR):
28 mkdir -p $@
29
30$(TMP_PLUGINS_DIR)/hg: $(TMP_PLUGINS_DIR)
31 ln -sf .. $@
32
33check:: build-inplace $(TMP_PLUGINS_DIR)/hg
34 BZR_PLUGIN_PATH=$(TMP_PLUGINS_DIR) $(DEBUGGER) $(PYTHON) $(PYTHON_OPTIONS) $(BZR) $(BZR_OPTIONS) selftest $(TEST_OPTIONS) $(TESTS)
3527
36check-verbose::28check-verbose::
37 $(MAKE) check TEST_OPTIONS=-v29 $(MAKE) check TEST_OPTIONS=-v
@@ -43,7 +35,7 @@
43 $(MAKE) check TEST_OPTIONS="--random=now --verbose --one"35 $(MAKE) check TEST_OPTIONS="--random=now --verbose --one"
4436
45show-plugins::37show-plugins::
46 BZR_PLUGIN_PATH=$(TMP_PLUGINS_DIR) $(BZR) plugins38 BZR_PLUGINS_AT=hg@$(shell pwd) $(BZR) plugins -v
4739
48lint::40lint::
49 $(PYLINT) -f parseable *.py */*.py41 $(PYLINT) -f parseable *.py */*.py
5042
=== modified file 'NEWS'
--- NEWS 2010-01-06 02:59:22 +0000
+++ NEWS 2010-08-05 19:14:41 +0000
@@ -21,6 +21,9 @@
2121
22 * Add extra constraints in sqlite cache. (Jelmer Vernooij)22 * Add extra constraints in sqlite cache. (Jelmer Vernooij)
2323
24 * New 'bzr hg-import' command similar to 'bzr svn-import' and
25 'bzr git-import'. (Jelmer Vernooij)
26
24 BUG FIXES27 BUG FIXES
2528
26 * Mark as compatible with Bazaar 2.1. (Jelmer Vernooij)29 * Mark as compatible with Bazaar 2.1. (Jelmer Vernooij)
@@ -32,13 +35,30 @@
3235
33 * Remove empty directories during fetch. (Jelmer Vernooij)36 * Remove empty directories during fetch. (Jelmer Vernooij)
3437
35 * Mark Mercurial 1.4 as supported. (#486899, Jelmer Vernooij)38 * Mark Mercurial 1.4 and 1.5 as supported. (#486899, Jelmer Vernooij)
3639
37 * Don't warn about development versions of Mercurial. (#492292, Jelmer 40 * Don't warn about development versions of Mercurial. (#492292, Jelmer
38 Vernooij)41 Vernooij)
3942
40 * Cope with unusual characters in changeset ids. (#498945, Jelmer Vernooij)43 * Cope with unusual characters in changeset ids. (#498945, Jelmer Vernooij)
4144
45 * Only mention Mercurial version to use yet. (#517345, Jelmer Vernooij)
46
47 * Only consider major version numbers in compatibility checks.
48 (#517343, Jelmer Vernooij)
49
50 * Cope with non-ascii characters in committer names, messages when
51 trying to create delta bases. (Jelmer Vernooij)
52
53 * Fix conversion of symlinks. (#594335, Max Bowser)
54
55 * Don't allow probing for Mercurial repositories over HTTP to break
56 bzr. (Jelmer Vernooij)
57
58 DOCUMENTATION
59
60 * Add some basic instructions in INSTALL. (Martin Pool)
61
420.1.0 2009-09-24620.1.0 2009-09-24
4363
44 Initial release.64 Initial release.
4565
=== modified file 'README'
--- README 2009-09-03 11:12:21 +0000
+++ README 2010-08-05 19:14:41 +0000
@@ -4,3 +4,15 @@
44
5This plugin requires recent versions of Bazaar and Mercurial to be 5This plugin requires recent versions of Bazaar and Mercurial to be
6installed to work.6installed to work.
7
8To install::
9
10 bzr branch lp:bzr-hg ~/.bazaar/plugins/hg
11
12To use:
13
14* Use bzr in folders with Mercurial repositories. (Readonly commands only.)
15
16* Use ``bzr send --format hg``
17
18* Use ``-r hg:SPEC`` to look up Mercurial native revisions.
719
=== modified file '__init__.py'
--- __init__.py 2009-12-20 03:17:42 +0000
+++ __init__.py 2010-08-05 19:14:41 +0000
@@ -44,9 +44,14 @@
44 format_registry as send_format_registry,44 format_registry as send_format_registry,
45 )45 )
4646
47_mercurial_loaded = False
47LockWarner = bzrlib.lockable_files._LockWarner48LockWarner = bzrlib.lockable_files._LockWarner
4849
49def lazy_load_mercurial():50def lazy_load_mercurial():
51 global _mercurial_loaded
52 if _mercurial_loaded:
53 return
54 _mercurial_loaded = True
50 import mercurial55 import mercurial
51 try:56 try:
52 from mercurial import demandimport57 from mercurial import demandimport
@@ -54,7 +59,8 @@
54 except ImportError:59 except ImportError:
55 pass60 pass
56 from mercurial.__version__ import version as hg_version61 from mercurial.__version__ import version as hg_version
57 if hg_version not in hg_compatible_versions and not "+" in hg_version:62 hg_major_version = ".".join(hg_version.split(".")[:2])
63 if hg_major_version not in hg_compatible_versions and not "+" in hg_version:
58 raise errors.DependencyNotPresent("mercurial",64 raise errors.DependencyNotPresent("mercurial",
59 'bzr-hg: Mercurial version %s not supported.' % hg_version)65 'bzr-hg: Mercurial version %s not supported.' % hg_version)
60 trace.mutter("bzr-hg: using Mercurial %s" % hg_version)66 trace.mutter("bzr-hg: using Mercurial %s" % hg_version)
@@ -157,9 +163,9 @@
157 result._hgrepo.pull(self._hgrepo)163 result._hgrepo.pull(self._hgrepo)
158 return result164 return result
159165
160 def create_branch(self):166 def create_branch(self, name=None):
161 """'create' a branch for this dir."""167 """'create' a branch for this dir."""
162 return self.open_branch()168 return self.open_branch(name=name)
163169
164 def create_repository(self, shared=False):170 def create_repository(self, shared=False):
165 """'create' a repository for this dir."""171 """'create' a repository for this dir."""
@@ -168,11 +174,29 @@
168 raise errors.IncompatibleFormat(self._format, self._format)174 raise errors.IncompatibleFormat(self._format, self._format)
169 return self.open_repository()175 return self.open_repository()
170176
171 def create_workingtree(self, shared=False):177 def create_workingtree(self, revision_id=None, from_branch=None,
178 accelerator_tree=None, hardlink=False):
172 """'create' a workingtree for this dir."""179 """'create' a workingtree for this dir."""
180 if revision_id is not None:
181 raise NotImplementedError("revision_id argument not yet supported")
182 if from_branch is not None:
183 raise NotImplementedError("from_branch argument not yet supported")
173 return self.open_workingtree()184 return self.open_workingtree()
174185
175 def get_branch_transport(self, branch_format):186 def destroy_branch(self, name=None):
187 if name is not None:
188 raise errors.NoColocatedBranchSupport(self)
189 raise errors.UnsupportedOperation(self.destroy_branch, self)
190
191 def destroy_workingtree(self):
192 raise errors.UnsupportedOperation(self.destroy_workingtree, self)
193
194 def destroy_repository(self):
195 raise errors.UnsupportedOperation(self.destroy_repository, self)
196
197 def get_branch_transport(self, branch_format, name=None):
198 if name is not None:
199 raise errors.NoColocatedBranchSupport(self)
176 if branch_format is None:200 if branch_format is None:
177 return self.transport201 return self.transport
178 if isinstance(branch_format, HgBzrDirFormat):202 if isinstance(branch_format, HgBzrDirFormat):
@@ -188,8 +212,10 @@
188 def needs_format_conversion(self, format=None):212 def needs_format_conversion(self, format=None):
189 return (format is not HgBzrDirFormat)213 return (format is not HgBzrDirFormat)
190214
191 def open_branch(self, ignored=None):215 def open_branch(self, name=None, ignored=None, unsupported=False):
192 """'crate' a branch for this dir."""216 """'create' a branch for this dir."""
217 if name is not None:
218 raise errors.NoColocatedBranchSupport(self)
193 from bzrlib.plugins.hg.branch import HgLocalBranch, HgRemoteBranch219 from bzrlib.plugins.hg.branch import HgLocalBranch, HgRemoteBranch
194 if self._hgrepo.local():220 if self._hgrepo.local():
195 branch_klass = HgLocalBranch221 branch_klass = HgLocalBranch
@@ -247,6 +273,9 @@
247 """We should write a converter."""273 """We should write a converter."""
248 return HgToSomethingConverter(format)274 return HgToSomethingConverter(format)
249275
276 def network_name(self):
277 return "hg"
278
250 def get_format_description(self):279 def get_format_description(self):
251 return "Mercurial Branch"280 return "Mercurial Branch"
252281
@@ -254,6 +283,9 @@
254 """Initialize a new .not dir in the base directory of a Transport."""283 """Initialize a new .not dir in the base directory of a Transport."""
255 return self.open(transport, _create=True)284 return self.open(transport, _create=True)
256285
286 def __eq__(self, other):
287 return type(self) == type(other)
288
257 @classmethod289 @classmethod
258 def _known_formats(self):290 def _known_formats(self):
259 return set([HgBzrDirFormat()])291 return set([HgBzrDirFormat()])
@@ -291,6 +323,7 @@
291 # Explicitly check for .hg directories here, so we avoid323 # Explicitly check for .hg directories here, so we avoid
292 # loading foreign branches through Mercurial.324 # loading foreign branches through Mercurial.
293 raise errors.NotBranchError(path=transport.base)325 raise errors.NotBranchError(path=transport.base)
326 import urllib2
294 try:327 try:
295 format.open(transport)328 format.open(transport)
296 except hg_errors.RepoError, e:329 except hg_errors.RepoError, e:
@@ -298,6 +331,9 @@
298 except hg_errors.Abort, e:331 except hg_errors.Abort, e:
299 trace.mutter('not a hg branch: %s', e)332 trace.mutter('not a hg branch: %s', e)
300 raise errors.NotBranchError(path=transport.base)333 raise errors.NotBranchError(path=transport.base)
334 except urllib2.HTTPError, e:
335 trace.mutter('not a hg branch: %s', e)
336 raise errors.NotBranchError(path=transport.base)
301 return format337 return format
302338
303339
@@ -313,6 +349,11 @@
313revspec_registry.register_lazy("hg:", "bzrlib.plugins.hg.revspec",349revspec_registry.register_lazy("hg:", "bzrlib.plugins.hg.revspec",
314 "RevisionSpec_hg")350 "RevisionSpec_hg")
315351
352from bzrlib.commands import (
353 plugin_cmds,
354 )
355plugin_cmds.register_lazy('cmd_hg_import', [], 'bzrlib.plugins.hg.commands')
356
316try:357try:
317 from bzrlib.revisionspec import dwim_revspecs358 from bzrlib.revisionspec import dwim_revspecs
318except ImportError:359except ImportError:
319360
=== modified file 'branch.py'
--- branch.py 2009-12-12 21:47:15 +0000
+++ branch.py 2010-08-05 19:14:41 +0000
@@ -104,6 +104,18 @@
104 return "long"104 return "long"
105105
106106
107class HgReadLock(object):
108
109 def __init__(self, unlock):
110 self.unlock = unlock
111
112
113class HgWriteLock(object):
114
115 def __init__(self, unlock):
116 self.unlock = unlock
117
118
107class HgBranch(ForeignBranch):119class HgBranch(ForeignBranch):
108 """An adapter to mercurial repositories for bzr Branch objects."""120 """An adapter to mercurial repositories for bzr Branch objects."""
109121
@@ -152,6 +164,7 @@
152164
153 def lock_write(self):165 def lock_write(self):
154 self.control_files.lock_write()166 self.control_files.lock_write()
167 return HgWriteLock(self.unlock)
155168
156 @needs_read_lock169 @needs_read_lock
157 def revision_history(self):170 def revision_history(self):
@@ -161,6 +174,7 @@
161174
162 def lock_read(self):175 def lock_read(self):
163 self.control_files.lock_read()176 self.control_files.lock_read()
177 return HgReadLock(self.unlock)
164178
165 def is_locked(self):179 def is_locked(self):
166 return self.control_files.is_locked()180 return self.control_files.is_locked()
@@ -168,11 +182,6 @@
168 def unlock(self):182 def unlock(self):
169 self.control_files.unlock()183 self.control_files.unlock()
170184
171 def clone(self, to_bzrdir, revision_id=None):
172 # hg repositories can only clone into hg repos.
173 # and have nothing to do as we follow the hg model.
174 return to_bzrdir.open_branch()
175
176 def get_stacked_on_url(self):185 def get_stacked_on_url(self):
177 raise errors.UnstackableBranchFormat(self._format, self.base)186 raise errors.UnstackableBranchFormat(self._format, self.base)
178187
@@ -208,7 +217,7 @@
208217
209 @staticmethod218 @staticmethod
210 def _get_branch_formats_to_test():219 def _get_branch_formats_to_test():
211 return None, None220 return []
212221
213 @staticmethod222 @staticmethod
214 def is_compatible(source, target):223 def is_compatible(source, target):
@@ -233,11 +242,11 @@
233 result = BranchPushResult()242 result = BranchPushResult()
234 result.source_branch = self.source243 result.source_branch = self.source
235 result.target_branch = self.target244 result.target_branch = self.target
236 result.old_revid = self.target.last_revision()245 result.old_revno, result.old_revid = self.target.last_revision_info()
237 inter = InterRepository.get(self.source.repository,246 inter = InterRepository.get(self.source.repository,
238 self.target.repository)247 self.target.repository)
239 inter.fetch(revision_id=stop_revision)248 inter.fetch(revision_id=stop_revision)
240 result.new_revid = self.target.last_revision()249 result.new_revno, result.new_revid = self.target.last_revision_info()
241 return result250 return result
242251
243252
@@ -249,7 +258,7 @@
249258
250 @staticmethod259 @staticmethod
251 def _get_branch_formats_to_test():260 def _get_branch_formats_to_test():
252 return None, None261 return []
253262
254 @staticmethod263 @staticmethod
255 def is_compatible(source, target):264 def is_compatible(source, target):
@@ -317,7 +326,7 @@
317326
318 @staticmethod327 @staticmethod
319 def _get_branch_formats_to_test():328 def _get_branch_formats_to_test():
320 return None, None329 return []
321330
322 @classmethod331 @classmethod
323 def is_compatible(self, source, target):332 def is_compatible(self, source, target):
324333
=== added file 'commands.py'
--- commands.py 1970-01-01 00:00:00 +0000
+++ commands.py 2010-08-05 19:14:41 +0000
@@ -0,0 +1,55 @@
1# Copyright (C) 2010 Jelmer Vernooij <jelmer@samba.org>
2#
3# This program is free software; you can redistribute it and/or modify
4# it under the terms of the GNU General Public License as published by
5# the Free Software Foundation; either version 2 of the License, or
6# (at your option) any later version.
7#
8# This program is distributed in the hope that it will be useful,
9# but WITHOUT ANY WARRANTY; without even the implied warranty of
10# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11# GNU General Public License for more details.
12#
13# You should have received a copy of the GNU General Public License
14# along with this program; if not, write to the Free Software
15# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16
17
18"""Commands specific to dealing with Mercurial branches."""
19
20
21from bzrlib import (
22 errors,
23 )
24from bzrlib.commands import (
25 Command,
26 )
27
28import os
29
30
31class cmd_hg_import(Command):
32 """Convert a Mercurial repository to a Bazaar repository.
33
34 """
35 _see_also = ['formats']
36 takes_args = ['from_location', 'to_location?']
37
38 def run(self, from_location, to_location=None):
39 from bzrlib.bzrdir import BzrDir
40 if to_location is None:
41 to_location = os.path.basename(from_location.rstrip("/\\"))
42 from_dir = BzrDir.open(from_location)
43 try:
44 to_dir = BzrDir.open(to_location)
45 except errors.NotBranchError:
46 to_dir = BzrDir.create(to_location)
47 try:
48 to_repo = to_dir.open_repository()
49 except errors.NoRepositoryPresent:
50 to_repo = to_dir.create_repository()
51 try:
52 to_branch = to_dir.open_branch()
53 except errors.NotBranchError:
54 to_branch = to_dir.create_branch()
55 to_branch.pull(from_dir.open_branch())
056
=== modified file 'fetch.py'
--- fetch.py 2009-12-18 21:43:34 +0000
+++ fetch.py 2010-08-05 19:14:41 +0000
@@ -357,9 +357,11 @@
357 key = (fileid, revision)357 key = (fileid, revision)
358 if kind == "symlink":358 if kind == "symlink":
359 self._symlink_targets[key] = fulltext359 self._symlink_targets[key] = fulltext
360 fulltext = ""360 bzr_fulltext = ""
361 record = FulltextContentFactory(key, [(fileid, p) for p in parents], osutils.sha_string(fulltext), fulltext)361 else:
362 self._text_metadata[key] = (record.sha1, len(fulltext))362 bzr_fulltext = fulltext
363 record = FulltextContentFactory(key, [(fileid, p) for p in parents], osutils.sha_string(bzr_fulltext), bzr_fulltext)
364 self._text_metadata[key] = (record.sha1, len(bzr_fulltext))
363 yield record365 yield record
364366
365 def _add_inventories(self, todo, mapping, pb):367 def _add_inventories(self, todo, mapping, pb):
@@ -484,7 +486,7 @@
484 revisions = filetext_map[fileid][node]486 revisions = filetext_map[fileid][node]
485 tp = self._find_most_recent_ancestor(revisions.keys(), revid)487 tp = self._find_most_recent_ancestor(revisions.keys(), revid)
486 text_parents.append(tp)488 text_parents.append(tp)
487 elif path2id(fileid) == path:489 elif path2id(path) == fileid:
488 # FIXME: Handle situation where path is not actually in parent490 # FIXME: Handle situation where path is not actually in parent
489 text_parents.append(parent[fileid].revision)491 text_parents.append(parent[fileid].revision)
490 filetext_map[fileid][manifest[path]][revid] = (kind, text_parents)492 filetext_map[fileid][manifest[path]][revid] = (kind, text_parents)
491493
=== modified file 'idmap.py'
--- idmap.py 2010-01-06 02:59:22 +0000
+++ idmap.py 2010-08-05 19:14:41 +0000
@@ -219,8 +219,8 @@
219219
220 def revids(self):220 def revids(self):
221 ret = set()221 ret = set()
222 for row in self.db.execute("select revid from revision").fetchall():222 ret.update((row for
223 ret.add(row[0])223 (row,) in self.db.execute("select revid from revision")))
224 return ret224 return ret
225225
226 def insert_revision(self, revid, manifest_id, changeset_id, mapping):226 def insert_revision(self, revid, manifest_id, changeset_id, mapping):
227227
=== modified file 'info.py'
--- info.py 2010-01-04 16:18:04 +0000
+++ info.py 2010-08-05 19:14:41 +0000
@@ -1,7 +1,7 @@
1bzr_plugin_name = 'hg'1bzr_plugin_name = 'hg'
22
3bzr_compatible_versions = [(1, x, 0) for x in [13, 14, 15, 16, 17, 18]] + \3bzr_compatible_versions = [(1, x, 0) for x in [13, 14, 15, 16, 17, 18]] + \
4 [(2, x, 0) for x in [0, 1]]4 [(2, x, 0) for x in [0, 1, 2]]
55
6bzr_minimum_version = bzr_compatible_versions[0]6bzr_minimum_version = bzr_compatible_versions[0]
77
@@ -11,4 +11,4 @@
1111
12bzr_control_formats = {"Mercurial": {'.hg/': None}}12bzr_control_formats = {"Mercurial": {'.hg/': None}}
1313
14hg_compatible_versions = ["1.3.1", "1.4", "1.4.1", "1.4.2"]14hg_compatible_versions = ["1.3", "1.4", "1.5", "1.6"]
1515
=== modified file 'mapping.py'
--- mapping.py 2009-11-26 21:33:32 +0000
+++ mapping.py 2010-08-05 19:14:41 +0000
@@ -288,7 +288,7 @@
288 return unescape_path(fileid[len("hg:"):])288 return unescape_path(fileid[len("hg:"):])
289289
290 def export_revision(self, rev, lossy=True, fileids={}):290 def export_revision(self, rev, lossy=True, fileids={}):
291 user = rev.committer.encode("utf-8")291 user = rev.committer
292 time = rev.timestamp292 time = rev.timestamp
293 timezone = -rev.timezone293 timezone = -rev.timezone
294 extra = {}294 extra = {}
@@ -320,18 +320,22 @@
320 extra["bzr-extra-parents"] = " ".join(rev.parent_ids[2:])320 extra["bzr-extra-parents"] = " ".join(rev.parent_ids[2:])
321 if fileids:321 if fileids:
322 extra["bzr-fileids"] = bencode.bencode(sorted(fileids.items()))322 extra["bzr-fileids"] = bencode.bencode(sorted(fileids.items()))
323 desc = rev.message.encode("utf-8")323 desc = rev.message
324 return (manifest, user, (time, timezone), desc, extra)324 return (manifest, user, (time, timezone), desc, extra)
325325
326 def import_revision(self, revid, parent_ids, hgrevid, manifest, user,326 def import_revision(self, revid, parent_ids, hgrevid, manifest, user,
327 (time, timezone), desc, extra):327 (time, timezone), desc, extra):
328 result = foreign.ForeignRevision(hgrevid, self, revid)328 result = foreign.ForeignRevision(hgrevid, self, revid)
329 result.parent_ids = parent_ids329 result.parent_ids = parent_ids
330 result.message = desc.decode("utf-8")330 if type(desc) != unicode:
331 raise AssertionError
332 result.message = desc
331 result.inventory_sha1 = ""333 result.inventory_sha1 = ""
332 result.timezone = -timezone334 result.timezone = -timezone
333 result.timestamp = time335 result.timestamp = time
334 result.committer = user.decode("utf-8")336 if type(user) != unicode:
337 raise AssertionError
338 result.committer = user
335 result.properties = {339 result.properties = {
336 'manifest': mercurial.node.hex(manifest)340 'manifest': mercurial.node.hex(manifest)
337 }341 }
338342
=== modified file 'parsers.py'
--- parsers.py 2009-11-26 21:33:32 +0000
+++ parsers.py 2010-08-05 19:14:41 +0000
@@ -25,7 +25,6 @@
25"""25"""
2626
27import mercurial.changelog27import mercurial.changelog
28import mercurial.encoding
29import mercurial.manifest28import mercurial.manifest
30import mercurial.mdiff29import mercurial.mdiff
31import mercurial.node30import mercurial.node
@@ -55,9 +54,13 @@
55 raise ValueError("empty username")54 raise ValueError("empty username")
56 if "\n" in user:55 if "\n" in user:
57 raise ValueError("username %s contains a newline" % repr(user))56 raise ValueError("username %s contains a newline" % repr(user))
57 if type(user) != unicode:
58 raise TypeError("user should be unicode string")
59 if type(desc) != unicode:
60 raise TypeError("desc should be unicode string")
5861
59 user = mercurial.encoding.fromlocal(user)62 user = user.encode("utf-8")
60 desc = mercurial.encoding.fromlocal(desc)63 desc = desc.encode("utf-8")
6164
62 if not isinstance(date, tuple):65 if not isinstance(date, tuple):
63 raise TypeError("date is not a tuple")66 raise TypeError("date is not a tuple")
@@ -79,10 +82,10 @@
79 :return: Tuple with (manifest, user, (time, timezone), files, desc, extra)82 :return: Tuple with (manifest, user, (time, timezone), files, desc, extra)
80 """83 """
81 last = text.index("\n\n")84 last = text.index("\n\n")
82 desc = mercurial.encoding.tolocal(text[last + 2:])85 desc = text[last + 2:].decode("utf-8")
83 l = text[:last].split('\n')86 l = text[:last].split('\n')
84 manifest = mercurial.node.bin(l[0])87 manifest = mercurial.node.bin(l[0])
85 user = mercurial.encoding.tolocal(l[1])88 user = l[1].decode("utf-8")
8689
87 extra_data = l[2].split(' ', 2)90 extra_data = l[2].split(' ', 2)
88 if len(extra_data) != 3:91 if len(extra_data) != 3:
8992
=== modified file 'repository.py'
--- repository.py 2009-12-15 20:34:14 +0000
+++ repository.py 2010-08-05 19:14:41 +0000
@@ -63,6 +63,9 @@
63 """63 """
64 rich_root_data = True64 rich_root_data = True
6565
66 def initialize(self, url, shared=False, _internal=False):
67 raise errors.UninitializableFormat(self)
68
66 def is_supported(self):69 def is_supported(self):
67 return True70 return True
6871
@@ -338,6 +341,7 @@
338341
339 def lookup_bzr_revision_id(self, revision_id):342 def lookup_bzr_revision_id(self, revision_id):
340 """See ForeignRepository.lookup_bzr_revision_id()."""343 """See ForeignRepository.lookup_bzr_revision_id()."""
344 assert type(revision_id) is str
341 # TODO: Handle round-tripped revisions345 # TODO: Handle round-tripped revisions
342 try:346 try:
343 return mapping_registry.revision_id_bzr_to_foreign(revision_id)347 return mapping_registry.revision_id_bzr_to_foreign(revision_id)
@@ -345,11 +349,12 @@
345 raise errors.NoSuchRevision(self, revision_id)349 raise errors.NoSuchRevision(self, revision_id)
346350
347 def get_revision(self, revision_id):351 def get_revision(self, revision_id):
352 assert type(revision_id) is str
348 hgrevid, mapping = self.lookup_bzr_revision_id(revision_id)353 hgrevid, mapping = self.lookup_bzr_revision_id(revision_id)
349 hgchange = self._hgrepo.changelog.read(hgrevid)354 hgchange = self._hgrepo.changelog.read(hgrevid)
350 hgparents = self._hgrepo.changelog.parents(hgrevid)355 hgparents = self._hgrepo.changelog.parents(hgrevid)
351 parent_ids = as_bzr_parents(hgparents, self.lookup_foreign_revision_id)356 parent_ids = as_bzr_parents(hgparents, self.lookup_foreign_revision_id)
352 return mapping.import_revision(revision_id, parent_ids, hgrevid, hgchange[0], hgchange[1], hgchange[2], hgchange[4], hgchange[5])[0]357 return mapping.import_revision(revision_id, parent_ids, hgrevid, hgchange[0], hgchange[1].decode("utf-8"), hgchange[2], hgchange[4].decode("utf-8"), hgchange[5])[0]
353358
354 def iter_inventories(self, revision_ids, ordering=None):359 def iter_inventories(self, revision_ids, ordering=None):
355 for revid in revision_ids:360 for revid in revision_ids:
356361
=== modified file 'setup.py'
--- setup.py 2009-11-26 21:33:32 +0000
+++ setup.py 2010-08-05 19:14:41 +0000
@@ -19,5 +19,5 @@
19 Mercurial branches in Bazaar.19 Mercurial branches in Bazaar.
20 """,20 """,
21 package_dir={'bzrlib.plugins.hg':'.'},21 package_dir={'bzrlib.plugins.hg':'.'},
22 packages=['bzrlib.plugins.hg']22 packages=['bzrlib.plugins.hg', 'bzrlib.plugins.hg.tests']
23 )23 )
2424
=== modified file 'tests/__init__.py'
--- tests/__init__.py 2009-10-14 21:02:20 +0000
+++ tests/__init__.py 2010-08-05 19:14:41 +0000
@@ -23,8 +23,15 @@
2323
24 suite = TestSuite()24 suite = TestSuite()
2525
26 testmod_names = ['test_branch', 'test_idmap', 'test_mapping', 'test_parsers', 'test_pull']26 testmod_names = [
27 27 'test_branch',
28 'test_dir',
29 'test_idmap',
30 'test_mapping',
31 'test_parsers',
32 'test_pull',
33 ]
34
28 suite.addTest(loader.loadTestsFromModuleNames(["%s.%s" % (__name__, i) for i in testmod_names]))35 suite.addTest(loader.loadTestsFromModuleNames(["%s.%s" % (__name__, i) for i in testmod_names]))
2936
30 return suite37 return suite
3138
=== added file 'tests/test_dir.py'
--- tests/test_dir.py 1970-01-01 00:00:00 +0000
+++ tests/test_dir.py 2010-08-05 19:14:41 +0000
@@ -0,0 +1,42 @@
1# Copyright (C) 2010 Jelmer Vernooij <jelmer@samba.org>
2
3# This program is free software; you can redistribute it and/or modify
4# it under the terms of the GNU General Public License as published by
5# the Free Software Foundation; either version 2 of the License, or
6# (at your option) any later version.
7
8# This program is distributed in the hope that it will be useful,
9# but WITHOUT ANY WARRANTY; without even the implied warranty of
10# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11# GNU General Public License for more details.
12
13# You should have received a copy of the GNU General Public License
14# along with this program; if not, write to the Free Software
15# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16
17from bzrlib.bzrdir import (
18 format_registry,
19 )
20
21from bzrlib.tests import (
22 TestCase,
23 )
24
25from bzrlib.plugins.hg import (
26 HgBzrDirFormat,
27 )
28
29
30class HgBzrDirFormatTests(TestCase):
31
32 def test_eq(self):
33 format1 = HgBzrDirFormat()
34 format2 = HgBzrDirFormat()
35 self.assertEquals(format1, format2)
36 self.assertEquals(format1, format1)
37 bzr_format = format_registry.make_bzrdir("default")
38 self.assertNotEquals(bzr_format, format1)
39
40 def test_network_name(self):
41 format = HgBzrDirFormat()
42 self.assertEquals("hg", format.network_name())
043
=== modified file 'tests/test_mapping.py'
--- tests/test_mapping.py 2009-11-16 23:06:52 +0000
+++ tests/test_mapping.py 2010-08-05 19:14:41 +0000
@@ -121,7 +121,7 @@
121 self.mapping.export_revision(rev)121 self.mapping.export_revision(rev)
122 self.assertEquals("Jelmer <foo>", user)122 self.assertEquals("Jelmer <foo>", user)
123 self.assertEquals(None, manifest)123 self.assertEquals(None, manifest)
124 self.assertEquals("ürk", desc)124 self.assertEquals(u"ürk", desc)
125 self.assertEquals({"bzr-revprop-something": "else", "foo": "bar"}, 125 self.assertEquals({"bzr-revprop-something": "else", "foo": "bar"},
126 extra)126 extra)
127127
128128
=== modified file 'tests/test_parsers.py'
--- tests/test_parsers.py 2009-10-10 12:19:36 +0000
+++ tests/test_parsers.py 2010-08-05 19:14:41 +0000
@@ -36,8 +36,8 @@
36commit36commit
37message""",37message""",
38 format_changeset(mercurial.node.nullid, ["myfile"],38 format_changeset(mercurial.node.nullid, ["myfile"],
39 "Jelmer Vernooij <jelmer@samba.org>",39 u"Jelmer Vernooij <jelmer@samba.org>",
40 (1253260798.0, -7200), "Some\ncommit\nmessage",40 (1253260798.0, -7200), u"Some\ncommit\nmessage",
41 {}))41 {}))
4242
43 def test_extra(self):43 def test_extra(self):
@@ -50,27 +50,27 @@
50commit50commit
51message""",51message""",
52 format_changeset(mercurial.node.nullid, ["myfile"],52 format_changeset(mercurial.node.nullid, ["myfile"],
53 "Jelmer Vernooij <jelmer@samba.org>",53 u"Jelmer Vernooij <jelmer@samba.org>",
54 (1253260798.0, -7200), "Some\ncommit\nmessage",54 (1253260798.0, -7200), u"Some\ncommit\nmessage",
55 {"extra": "data", "more":"extra"}))55 {"extra": "data", "more":"extra"}))
5656
57 def test_invalid_author(self):57 def test_invalid_author(self):
58 self.assertRaises(ValueError, format_changeset, 58 self.assertRaises(ValueError, format_changeset,
59 mercurial.node.nullid, ["myfile"],59 mercurial.node.nullid, ["myfile"],
60 "",60 u"",
61 (1253260798.0, -7200), "Some\ncommit\nmessage",61 (1253260798.0, -7200), u"Some\ncommit\nmessage",
62 {})62 {})
63 self.assertRaises(ValueError, format_changeset, 63 self.assertRaises(ValueError, format_changeset,
64 mercurial.node.nullid, ["myfile"],64 mercurial.node.nullid, ["myfile"],
65 "Jelmer\nVernooij",65 u"Jelmer\nVernooij",
66 (1253260798.0, -7200), "Some\ncommit\nmessage",66 (1253260798.0, -7200), u"Some\ncommit\nmessage",
67 {})67 {})
6868
69 def test_invalid_date(self):69 def test_invalid_date(self):
70 self.assertRaises(TypeError, format_changeset, 70 self.assertRaises(TypeError, format_changeset,
71 mercurial.node.nullid, ["myfile"],71 mercurial.node.nullid, ["myfile"],
72 "Jelmer Vernooij <jelmer@samba.org>",72 u"Jelmer Vernooij <jelmer@samba.org>",
73 1253260798, "Some\ncommit\nmessage",73 1253260798, u"Some\ncommit\nmessage",
74 {})74 {})
7575
7676
@@ -78,8 +78,8 @@
7878
79 def test_simple(self):79 def test_simple(self):
80 self.assertEquals((mercurial.node.nullid, 80 self.assertEquals((mercurial.node.nullid,
81 "Jelmer Vernooij <jelmer@samba.org>",81 u"Jelmer Vernooij <jelmer@samba.org>",
82 (1253260798.0, -7200), ["myfile"], "Some\ncommit\nmessage",82 (1253260798.0, -7200), ["myfile"], u"Some\ncommit\nmessage",
83 {}), parse_changeset("""000000000000000000000000000000000000000083 {}), parse_changeset("""0000000000000000000000000000000000000000
84Jelmer Vernooij <jelmer@samba.org>84Jelmer Vernooij <jelmer@samba.org>
851253260798 -7200851253260798 -7200
@@ -91,8 +91,8 @@
9191
92 def test_extra(self):92 def test_extra(self):
93 self.assertEquals((mercurial.node.nullid, 93 self.assertEquals((mercurial.node.nullid,
94 "Jelmer Vernooij <jelmer@samba.org>",94 u"Jelmer Vernooij <jelmer@samba.org>",
95 (1253260798.0, -7200), ["myfile"], "Some\ncommit\nmessage",95 (1253260798.0, -7200), ["myfile"], u"Some\ncommit\nmessage",
96 {"date": "extra"}), 96 {"date": "extra"}),
97 parse_changeset("""000000000000000000000000000000000000000097 parse_changeset("""0000000000000000000000000000000000000000
98Jelmer Vernooij <jelmer@samba.org>98Jelmer Vernooij <jelmer@samba.org>

Subscribers

People subscribed via source and target branches