From 5117ba2c51fb25b4562cb28b9682b37dada6ce19 Mon Sep 17 00:00:00 2001 From: Kentaro Wada Date: Sun, 26 Jul 2015 18:34:32 +0900 Subject: [PATCH 01/11] [wstool/cli_common.py] Add dict key check for remote_revision --- src/wstool/cli_common.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/wstool/cli_common.py b/src/wstool/cli_common.py index bc68306..c8a7072 100644 --- a/src/wstool/cli_common.py +++ b/src/wstool/cli_common.py @@ -164,6 +164,8 @@ def get_info_table_elements(basepath, entries): line['curr_version'] = None if not 'version' in line: line['version'] = None + if not 'remote_revision' in line: + line['remote_revision'] = None if not 'curr_version_label' in line: line['curr_version_label'] = None output_dict = {'scm': line['scm'], From f6b7941ceae21ddbd37a1dde02d1335b8e679fe4 Mon Sep 17 00:00:00 2001 From: Kentaro Wada Date: Sun, 26 Jul 2015 18:36:53 +0900 Subject: [PATCH 02/11] [test/local/mock_client.py] Add get_remote_version method to MockClient --- test/local/mock_client.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/test/local/mock_client.py b/test/local/mock_client.py index 72c5c1d..a9a4af5 100644 --- a/test/local/mock_client.py +++ b/test/local/mock_client.py @@ -47,7 +47,8 @@ def __init__(self, vcs_presence=False, url="mockurl", actualversion=None, - specversion=None): + specversion=None, + remoteversion=None): self.scmtype = scmtype self.path_exists_flag = path_exists self.checkout_success = checkout_success @@ -58,6 +59,7 @@ def __init__(self, self.updated = False self.actualversion = actualversion self.specversion = specversion + self.remoteversion = remoteversion def get_vcs_type_name(self): return self.scmtype @@ -71,6 +73,9 @@ def get_version(self, revision=None): else: return self.specversion + def get_remote_version(self): + return self.remoteversion + def get_status(self, basepath=None, untracked=False): return self.scmtype + " mockstatus%s,%s" % (basepath, untracked) From 5d09243bed554ace8a7fb62ed1b7a681398f1523 Mon Sep 17 00:00:00 2001 From: Kentaro Wada Date: Sun, 26 Jul 2015 18:37:06 +0900 Subject: [PATCH 03/11] [test/local/mock_client.py] Add get_current_version_label method to MockClient --- test/local/mock_client.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/test/local/mock_client.py b/test/local/mock_client.py index a9a4af5..027b0d7 100644 --- a/test/local/mock_client.py +++ b/test/local/mock_client.py @@ -76,6 +76,9 @@ def get_version(self, revision=None): def get_remote_version(self): return self.remoteversion + def get_current_version_label(self): + return self.scmtype + "mockcurrentversionlabel" + def get_status(self, basepath=None, untracked=False): return self.scmtype + " mockstatus%s,%s" % (basepath, untracked) From 47a596c9bff268bcd4eb19e95b140a67e72d1e29 Mon Sep 17 00:00:00 2001 From: Kentaro Wada Date: Sun, 26 Jul 2015 18:47:40 +0900 Subject: [PATCH 04/11] [test/local/test_cli.py] fix info table test --- test/local/test_cli.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/test/local/test_cli.py b/test/local/test_cli.py index bec834c..fc5a0e0 100644 --- a/test/local/test_cli.py +++ b/test/local/test_cli.py @@ -558,7 +558,7 @@ def test_info_table(self): 'localname': 'localname', 'specversion': None, 'actualversion': None}] - self.assertEqual(["localname", "svn", "tags/tagname", "some.svn.tags.server/some/"], _nth_line_split(-1, wstool.cli_common.get_info_table(basepath, entries))) + self.assertEqual(["localname", "svn", "version", "(tags/tagname)", "some.svn.tags.server/some/"], _nth_line_split(-1, wstool.cli_common.get_info_table(basepath, entries))) entries = [{'scm': 'svn', 'uri': 'https://some.svn.tags.server/some/branches/branchname', 'curr_uri': None, @@ -566,7 +566,7 @@ def test_info_table(self): 'localname': 'localname', 'specversion': None, 'actualversion': None}] - self.assertEqual(["localname", "svn", "branches/branchname", "some.svn.tags.server/some/"], _nth_line_split(-1, wstool.cli_common.get_info_table(basepath, entries))) + self.assertEqual(["localname", "svn", "version", "(branches/branchname)", "some.svn.tags.server/some/"], _nth_line_split(-1, wstool.cli_common.get_info_table(basepath, entries))) entries = [{'scm': 'svn', 'uri': 'https://some.svn.tags.server/some/trunk', 'curr_uri': None, @@ -574,7 +574,7 @@ def test_info_table(self): 'localname': 'localname', 'specversion': None, 'actualversion': None}] - self.assertEqual(["localname", "svn", "trunk", "some.svn.tags.server/some/"], _nth_line_split(-1, wstool.cli_common.get_info_table(basepath, entries))) + self.assertEqual(["localname", "svn", "version", "(trunk)", "some.svn.tags.server/some/"], _nth_line_split(-1, wstool.cli_common.get_info_table(basepath, entries))) entries = [{'scm': 'svn', 'uri': 'https://some.svn.tags.server/some/branches/branchname', 'curr_uri': 'https://some.svn.tags.server/some/tags/tagname', From 8ddcf40188714cdb5c149e157b3a4ed6bc27006c Mon Sep 17 00:00:00 2001 From: Kentaro Wada Date: Sun, 26 Jul 2015 19:32:03 +0900 Subject: [PATCH 05/11] [test/local/test_diff_functions_git.py] Get clearer failure output --- test/local/test_diff_functions_git.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/local/test_diff_functions_git.py b/test/local/test_diff_functions_git.py index db4c591..f32b63c 100644 --- a/test/local/test_diff_functions_git.py +++ b/test/local/test_diff_functions_git.py @@ -220,7 +220,7 @@ def test_wstool_detailed_localpath_info(self): wstool_main(cmd) output = output.getvalue() tokens = _nth_line_split(-2, output) - self.assertEqual(['clone', 'git', 'master', self.version_end, os.path.join(self.test_root_path, 'remote')], tokens, output) + self.assertEqual(['clone', 'git', 'master', self.version_end, os.path.join(self.test_root_path, 'remote')], tokens) clone_path = os.path.join(self.local_path, "clone") # make local modifications check From 1802ffa113e259ef80f7589f6eaffd2025f02d36 Mon Sep 17 00:00:00 2001 From: Kentaro Wada Date: Sun, 26 Jul 2015 19:38:08 +0900 Subject: [PATCH 06/11] [test_diff_functions_git.py] Resolve existing test for git --- test/local/test_diff_functions_git.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/test/local/test_diff_functions_git.py b/test/local/test_diff_functions_git.py index f32b63c..f1f354c 100644 --- a/test/local/test_diff_functions_git.py +++ b/test/local/test_diff_functions_git.py @@ -220,7 +220,7 @@ def test_wstool_detailed_localpath_info(self): wstool_main(cmd) output = output.getvalue() tokens = _nth_line_split(-2, output) - self.assertEqual(['clone', 'git', 'master', self.version_end, os.path.join(self.test_root_path, 'remote')], tokens) + self.assertEqual(['clone', 'git', 'master', '(-)', self.version_end, os.path.join(self.test_root_path, 'remote')], tokens) clone_path = os.path.join(self.local_path, "clone") # make local modifications check @@ -229,7 +229,7 @@ def test_wstool_detailed_localpath_info(self): wstool_main(cmd) output = output.getvalue() tokens = _nth_line_split(-2, output) - self.assertEqual(['clone', 'M', 'git', 'master', self.version_end, os.path.join(self.test_root_path, 'remote')], tokens) + self.assertEqual(['clone', 'M', 'git', 'master', '(-)', self.version_end, os.path.join(self.test_root_path, 'remote')], tokens) subprocess.check_call(["rm", ".rosinstall"], cwd=self.local_path) _add_to_file(os.path.join(self.local_path, ".rosinstall"), "- other: {local-name: ../ros}\n- git: {local-name: clone, uri: ../remote, version: \"footag\"}") @@ -237,7 +237,7 @@ def test_wstool_detailed_localpath_info(self): wstool_main(cmd) output = output.getvalue() tokens = _nth_line_split(-2, output) - self.assertEqual(['clone', 'MRV', 'git', 'footag', 'master', self.version_end, "(%s)" % self.version_init, os.path.join(self.test_root_path, 'remote')], tokens) + self.assertEqual(['clone', 'MV', 'git', 'master', '(footag)', self.version_end, "(%s)" % self.version_init, os.path.join(self.test_root_path, 'remote')], tokens) # using a denormalized local-name here subprocess.check_call(["rm", ".rosinstall"], cwd=self.local_path) @@ -246,7 +246,7 @@ def test_wstool_detailed_localpath_info(self): wstool_main(cmd) output = output.getvalue() tokens = _nth_line_split(-2, output) - self.assertEqual(['clone', 'MRV', 'git', 'footag', 'master', self.version_end, "(%s)" % + self.assertEqual(['clone', 'MV', 'git', 'master', '(footag)', self.version_end, "(%s)" % self.version_init, os.path.join(self.test_root_path, 'remote')], tokens) # using an absolute path to clone dir here @@ -256,7 +256,7 @@ def test_wstool_detailed_localpath_info(self): wstool_main(cmd) output = output.getvalue() tokens = _nth_line_split(-2, output) - self.assertEqual([clone_path, 'MRV', 'git', 'footag', 'master', self.version_end, "(%s)" % self.version_init, os.path.join(self.test_root_path, 'remote')], tokens) + self.assertEqual([clone_path, 'MV', 'git', 'master', '(footag)', self.version_end, "(%s)" % self.version_init, os.path.join(self.test_root_path, 'remote')], tokens) # using an absolute path here where relative path is shorter to display (also checks x for missing) subprocess.check_call(["rm", ".rosinstall"], cwd=self.local_path) From 9448ffa90d885761624455cc987065a934644fad Mon Sep 17 00:00:00 2001 From: Kentaro Wada Date: Sun, 26 Jul 2015 19:39:01 +0900 Subject: [PATCH 07/11] [test_diff_functions_hg.py] Get clearer failure output --- test/local/test_diff_functions_hg.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/local/test_diff_functions_hg.py b/test/local/test_diff_functions_hg.py index b502fd0..016aaac 100644 --- a/test/local/test_diff_functions_hg.py +++ b/test/local/test_diff_functions_hg.py @@ -221,7 +221,7 @@ def test_rosinstall_detailed_locapath_info(self): wstool_main(cmd) output = output.getvalue() tokens = _nth_line_split(-2, output) - self.assertEqual(['clone', 'hg', self.version_end, os.path.join(self.test_root_path, 'remote')], tokens, output) + self.assertEqual(['clone', 'hg', self.version_end, os.path.join(self.test_root_path, 'remote')], tokens) clone_path = os.path.join(self.local_path, "clone") # make local modifications check From e9f05e8ea10140e51997e4a7ed6456107465d57b Mon Sep 17 00:00:00 2001 From: Kentaro Wada Date: Sun, 26 Jul 2015 19:41:21 +0900 Subject: [PATCH 08/11] [test_diff_functions_hg.py] Resolve existing test for hg --- test/local/test_diff_functions_hg.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/test/local/test_diff_functions_hg.py b/test/local/test_diff_functions_hg.py index 016aaac..86f2bb6 100644 --- a/test/local/test_diff_functions_hg.py +++ b/test/local/test_diff_functions_hg.py @@ -221,7 +221,7 @@ def test_rosinstall_detailed_locapath_info(self): wstool_main(cmd) output = output.getvalue() tokens = _nth_line_split(-2, output) - self.assertEqual(['clone', 'hg', self.version_end, os.path.join(self.test_root_path, 'remote')], tokens) + self.assertEqual(['clone', 'hg', 'default', '(-)', self.version_end, os.path.join(self.test_root_path, 'remote')], tokens) clone_path = os.path.join(self.local_path, "clone") # make local modifications check @@ -231,7 +231,7 @@ def test_rosinstall_detailed_locapath_info(self): wstool_main(cmd) output = output.getvalue() tokens = _nth_line_split(-2, output) - self.assertEqual(['clone', 'M', 'hg', self.version_end, os.path.join(self.test_root_path, 'remote')], tokens) + self.assertEqual(['clone', 'M', 'hg', 'default', '(-)', self.version_end, os.path.join(self.test_root_path, 'remote')], tokens) subprocess.check_call(["rm", ".rosinstall"], cwd=self.local_path) _add_to_file(os.path.join(self.local_path, ".rosinstall"), "- other: {local-name: ../ros}\n- hg: {local-name: clone, uri: ../remote, version: \"footag\"}") @@ -240,7 +240,7 @@ def test_rosinstall_detailed_locapath_info(self): wstool_main(cmd) output = output.getvalue() tokens = _nth_line_split(-2, output) - self.assertEqual(['clone', 'MV', 'hg', 'footag', self.version_end, "(%s)" % self.version_init, os.path.join(self.test_root_path, 'remote')], tokens) + self.assertEqual(['clone', 'MV', 'hg', 'default', '(footag)', self.version_end, "(%s)" % self.version_init, os.path.join(self.test_root_path, 'remote')], tokens) subprocess.check_call(["rm", "-rf", "clone"], cwd=self.local_path) os.chdir(self.test_root_path) @@ -248,4 +248,4 @@ def test_rosinstall_detailed_locapath_info(self): wstool_main(cmd) output = output.getvalue() tokens = _nth_line_split(-2, output) - self.assertEqual(['clone', 'x', 'hg', 'footag', os.path.join(self.test_root_path, 'remote')], tokens) + self.assertEqual(['clone', 'x', 'hg', '(footag)', os.path.join(self.test_root_path, 'remote')], tokens) From c86e2e41143863afe8cbf075bc191a5ec3b6a420 Mon Sep 17 00:00:00 2001 From: Kentaro Wada Date: Sun, 26 Jul 2015 19:42:12 +0900 Subject: [PATCH 09/11] [test_diff_functions_svn.py] Resolve existing test for svn --- test/local/test_diff_functions_svn.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/local/test_diff_functions_svn.py b/test/local/test_diff_functions_svn.py index fc32146..2cc8225 100644 --- a/test/local/test_diff_functions_svn.py +++ b/test/local/test_diff_functions_svn.py @@ -269,4 +269,4 @@ def test_rosinstall_detailed_locapath_info(self): wstool_main(cmd) output = output.getvalue() tokens = _nth_line_split(-2, output) - self.assertEqual(['clone', 'x', 'svn', '1', self.svn_uri], tokens) + self.assertEqual(['clone', 'x', 'svn', '(1)', self.svn_uri], tokens) From 72bb71f5273893ca2801014359ecb7c53176ea21 Mon Sep 17 00:00:00 2001 From: Kentaro Wada Date: Sun, 26 Jul 2015 20:24:29 +0900 Subject: [PATCH 10/11] [test_diff_functions_git.py] Add assertion for missing --- test/local/test_diff_functions_git.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/test/local/test_diff_functions_git.py b/test/local/test_diff_functions_git.py index f1f354c..8b95b15 100644 --- a/test/local/test_diff_functions_git.py +++ b/test/local/test_diff_functions_git.py @@ -214,7 +214,7 @@ def setUp(self): sys.stdout = sys.__stdout__ def test_wstool_detailed_localpath_info(self): - cmd = ["wstool", "info", "-t", "ws"] + cmd = ["wstool", "info", "-t", "ws", "--managed-only"] os.chdir(self.test_root_path) sys.stdout = output = StringIO() wstool_main(cmd) @@ -265,3 +265,5 @@ def test_wstool_detailed_localpath_info(self): wstool_main(cmd) output = output.getvalue() tokens = _nth_line_split(-2, output) + localname = os.path.join(os.path.dirname(self.local_path), 'foo') + self.assertEqual([localname, 'x', 'git', '(footag)', os.path.join(self.test_root_path, 'remote')], tokens) From 8e0b75447095324e7f54942e64ae87c6d244789e Mon Sep 17 00:00:00 2001 From: Kentaro Wada Date: Sun, 26 Jul 2015 21:04:36 +0900 Subject: [PATCH 11/11] [test_diff_functions_git.py] Test when current branch tracks other version --- test/local/test_diff_functions_git.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/test/local/test_diff_functions_git.py b/test/local/test_diff_functions_git.py index 8b95b15..6237d14 100644 --- a/test/local/test_diff_functions_git.py +++ b/test/local/test_diff_functions_git.py @@ -233,11 +233,30 @@ def test_wstool_detailed_localpath_info(self): subprocess.check_call(["rm", ".rosinstall"], cwd=self.local_path) _add_to_file(os.path.join(self.local_path, ".rosinstall"), "- other: {local-name: ../ros}\n- git: {local-name: clone, uri: ../remote, version: \"footag\"}") + # test when version is different sys.stdout = output = StringIO() wstool_main(cmd) output = output.getvalue() tokens = _nth_line_split(-2, output) self.assertEqual(['clone', 'MV', 'git', 'master', '(footag)', self.version_end, "(%s)" % self.version_init, os.path.join(self.test_root_path, 'remote')], tokens) + # test when tracking branch is different from current branch + subprocess.check_call(["git", "checkout", "-b", "test_branch"], cwd=clone_path) + subprocess.check_call(["git", "config", "--replace-all", "branch.test_branch.remote", "origin"], cwd=clone_path) + subprocess.check_call(["git", "config", "--replace-all", "branch.test_branch.merge", "master"], cwd=clone_path) + sys.stdout = output = StringIO() + wstool_main(cmd) + output = output.getvalue() + tokens = _nth_line_split(-2, output) + self.assertEqual(['clone', 'MV', 'git', 'test_branch', '<', 'master', '(footag)', self.version_end, "(%s)" % self.version_init, os.path.join(self.test_root_path, 'remote')], tokens) + # test when remote is different from origin + subprocess.check_call(["git", "config", "--replace-all", "branch.test_branch.remote", "remote2"], cwd=clone_path) + sys.stdout = output = StringIO() + wstool_main(cmd) + output = output.getvalue() + tokens = _nth_line_split(-2, output) + self.assertEqual(['clone', 'MV', 'git', 'test_branch', '<', 'remote2/master', '(footag)', self.version_end, "(%s)" % self.version_init, os.path.join(self.test_root_path, 'remote')], tokens) + # return branch back to master + subprocess.check_call(["git", "checkout", "master"], cwd=clone_path) # using a denormalized local-name here subprocess.check_call(["rm", ".rosinstall"], cwd=self.local_path)