Permalink
Browse files

added bzr.

  • Loading branch information...
1 parent 432837e commit f9deadf7bef7f0e8765607e0037793b509907116 @alex committed Jan 22, 2011
Showing with 49 additions and 8 deletions.
  1. +22 −8 vcstranslator_project/apps/translator/tests.py
  2. +27 −0 vcstranslator_project/apps/translator/utils.py
@@ -11,9 +11,9 @@ def test_clean_command(self):
self.assertFalse(f.is_valid())
self.assertEqual(f.errors["command"], ["This field is required."])
- f = TranslationForm({"command": "bzr commit", "vcs": "git"})
+ f = TranslationForm({"command": "arch commit", "vcs": "git"})
self.assertFalse(f.is_valid())
- self.assertEqual(f.errors["command"], ["Command must start with a valid VCS (git, hg, svn)."])
+ self.assertEqual(f.errors["command"], ["Command must start with a valid VCS (bzr, git, hg, svn)."])
f = TranslationForm({"command": "svn commit", "vcs": "git"})
self.assertTrue(f.is_valid())
@@ -52,12 +52,12 @@ def test_svn_to_git(self):
self.assert_translates(t, "status", "git status")
def test_git_to_svn(self):
- t = Translator("git", "svn")
- self.assert_translates(t, "pull", "svn up")
- self.assert_translates(t, "clone", "svn checkout")
- self.assert_translates(t, "status", "svn status")
- self.assert_translates(t, "diff", "svn diff")
- self.assert_cant_handle(t, "push")
+ t = Translator("git", "svn")
+ self.assert_translates(t, "pull", "svn up")
+ self.assert_translates(t, "clone", "svn checkout")
+ self.assert_translates(t, "status", "svn status")
+ self.assert_translates(t, "diff", "svn diff")
+ self.assert_cant_handle(t, "push")
def test_hg_to_git(self):
t = Translator("hg", "git")
@@ -92,6 +92,20 @@ def hg_to_svn(self):
t = Translator("hg", "svn")
self.assert_translates(t, "diff", "svn diff")
+ def test_git_to_bzr(self):
+ t = Translator("git", "bzr")
+ self.assert_translates(t, "init", "bzr init")
+ self.assert_translates(t, "clone", "bzr branch")
+ self.assert_translates(t, "status", "bzr status")
+ self.assert_translates(t, "pull", "bzr pull")
+ self.assert_translates(t, "push", "bzr push")
+
+ def test_bzr_to_git(self):
+ t = Translator("bzr", "git")
+ self.assert_translates(t, "pull", "git fetch")
+ self.assert_translates(t, "commit", "git commit -a")
+ self.assert_translates(t, "push", "git push")
+
def test_cant_handle_yes(self):
t = Translator("svn", "git")
self.assert_cant_handle_yet(t, "commit some/file")
@@ -15,6 +15,32 @@ def translate(self, command):
raise CantHandleYet
return meth(command)
+class BzrTranslator(BaseTranslator):
+ def parse(self, command):
+ parts = command.split()
+ if parts == ["pull"]:
+ return Fetch()
+ elif parts == ["commit"]:
+ return Commit(files=Commit.ALL, push=False)
+ elif parts == ["push"]:
+ return Push()
+
+ def translate_init(self, command):
+ return "bzr init"
+
+ def translate_clone(self, command):
+ return "bzr branch"
+
+ def translate_status(self, command):
+ return "bzr status"
+
+ def translate_pull(self, command):
+ return "bzr pull"
+
+ def translate_push(self, command):
+ return "bzr push"
+
+
class GitTranslator(BaseTranslator):
def parse(self, command):
parts = command.split()
@@ -172,6 +198,7 @@ def translate_diff(self, command):
class Translator(object):
vcs = SortedDict([
+ ("bzr", BzrTranslator),
("git", GitTranslator),
("hg", HgTranslator),
("svn", SVNTranslator),

0 comments on commit f9deadf

Please sign in to comment.