From de5e4d10f1fdb05029161e112c279a0fc799291e Mon Sep 17 00:00:00 2001 From: Luke Plant Date: Sat, 22 Jan 2011 02:41:32 +0000 Subject: [PATCH 1/2] Added translation of 'hg record' to git. --- vcstranslator_project/apps/translator/tests.py | 1 + vcstranslator_project/apps/translator/utils.py | 11 ++++++++++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/vcstranslator_project/apps/translator/tests.py b/vcstranslator_project/apps/translator/tests.py index 3357f20..fee60de 100644 --- a/vcstranslator_project/apps/translator/tests.py +++ b/vcstranslator_project/apps/translator/tests.py @@ -66,6 +66,7 @@ def test_hg_to_git(self): self.assert_translates(t, "push", "git push") self.assert_translates(t, "diff", "git diff") self.assert_translates(t, "paths", "git remote -v") + self.assert_translates(t, "record", "git add -p && git commit") def test_git_to_hg(self): t = Translator("git", "hg") diff --git a/vcstranslator_project/apps/translator/utils.py b/vcstranslator_project/apps/translator/utils.py index cd1882d..283a23a 100644 --- a/vcstranslator_project/apps/translator/utils.py +++ b/vcstranslator_project/apps/translator/utils.py @@ -57,8 +57,13 @@ def translate_clone(self, command): def translate_add(self, command): cmd = "git add" + if command.interactive: + # Prefer '-p' to '-i' as it is much easier + cmd += " -p" if command.files: cmd += " %s" % " ".join(f.path for f in command.files) + if command.commit: + cmd += " && git commit" return cmd def translate_pull(self, command): @@ -92,6 +97,8 @@ def parse(self, command): return Diff() elif parts == ["paths"]: return Remote(verbose=True) + elif parts == ["record"]: + return Add(interactive=True, commit=True) def translate_commit(self, command): if command.files is command.ALL: @@ -250,8 +257,10 @@ class Clone(Command): pass class Add(Command): - def __init__(self, files): + def __init__(self, files=None, interactive=False, commit=False): self.files = files + self.interactive = interactive + self.commit = commit class Status(Command): pass From 8cf53aea1457927a8a733057415df20e9e493c35 Mon Sep 17 00:00:00 2001 From: Luke Plant Date: Sat, 19 Feb 2011 19:38:31 +0000 Subject: [PATCH 2/2] Added translation for 'hg outgoing' --- vcstranslator_project/apps/translator/tests.py | 1 + vcstranslator_project/apps/translator/utils.py | 7 ++++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/vcstranslator_project/apps/translator/tests.py b/vcstranslator_project/apps/translator/tests.py index bb0d94c..352968b 100644 --- a/vcstranslator_project/apps/translator/tests.py +++ b/vcstranslator_project/apps/translator/tests.py @@ -72,6 +72,7 @@ def test_hg_to_git(self): self.assert_translates(t, "record", "git add -p && git commit") self.assert_translates(t, "log", "git log --all") self.assert_translates(t, "", "git") + self.assert_translates(t, "outgoing", "git log origin..HEAD") def test_git_to_hg(self): t = Translator("git", "hg") diff --git a/vcstranslator_project/apps/translator/utils.py b/vcstranslator_project/apps/translator/utils.py index 7cb0fe3..09a1b8d 100644 --- a/vcstranslator_project/apps/translator/utils.py +++ b/vcstranslator_project/apps/translator/utils.py @@ -126,6 +126,8 @@ def translate_status(self, command): return "git status" def translate_log(self, command): + if command.outgoing: + return "git log origin..HEAD" if command.files is not command.ALL or command.branches is not command.ALL: return return "git log --all" @@ -163,6 +165,8 @@ def parse(self, command): return Status() elif parts == ["log"]: return Log(branches=Log.ALL, files=Log.ALL) + elif parts == ["outgoing"]: + return Log(branches=Log.ALL, files=Log.ALL, outgoing=True) elif parts[0] == "revert" and len(parts) == 2: return Revert(files=[SomeFile(parts[1])]) @@ -360,9 +364,10 @@ def __init__(self, verbose): self.verbose = verbose class Log(Command): - def __init__(self, branches, files): + def __init__(self, branches, files, outgoing=False): self.branches = branches self.files = files + self.outgoing = outgoing class Help(Command): def __init__(self, useless=False):