Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/wstool/cli_common.py
Original file line number Diff line number Diff line change
Expand Up @@ -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'],
Expand Down
10 changes: 9 additions & 1 deletion test/local/mock_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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)

Expand Down
6 changes: 3 additions & 3 deletions test/local/test_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -558,23 +558,23 @@ 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,
'version': 'version',
'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,
'version': 'version',
'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',
Expand Down
33 changes: 27 additions & 6 deletions test/local/test_diff_functions_git.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)
Expand All @@ -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
Expand All @@ -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)
Expand All @@ -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)
8 changes: 4 additions & 4 deletions test/local/test_diff_functions_hg.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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\"}")
Expand All @@ -240,12 +240,12 @@ 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)
sys.stdout = output = StringIO()
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)
2 changes: 1 addition & 1 deletion test/local/test_diff_functions_svn.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)