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'], diff --git a/test/local/mock_client.py b/test/local/mock_client.py index 72c5c1d..027b0d7 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,12 @@ def get_version(self, revision=None): else: return self.specversion + 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) 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', diff --git a/test/local/test_diff_functions_git.py b/test/local/test_diff_functions_git.py index db4c591..6237d14 100644 --- a/test/local/test_diff_functions_git.py +++ b/test/local/test_diff_functions_git.py @@ -214,13 +214,13 @@ 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) 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 @@ -229,15 +229,34 @@ 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\"}") + # 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', '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', '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) @@ -246,7 +265,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 +275,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) @@ -265,3 +284,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) diff --git a/test/local/test_diff_functions_hg.py b/test/local/test_diff_functions_hg.py index b502fd0..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, output) + 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) 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)