Skip to content
This repository was archived by the owner on Jun 25, 2020. It is now read-only.
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
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ python:
- "2.7"
- "3.2"
- "3.3"
- "3.4"
# command to install dependencies
install:
# develop seems to be required by travis since 02/2013
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ def get_version():
packages=['wstool'],
package_dir={'': 'src'},
# rosinstall dependency to be kept in order not to break ros hydro install instructions
install_requires=['vcstools>=0.1.34', 'pyyaml'],
install_requires=['vcstools>=0.1.37', 'pyyaml'],
scripts=["scripts/wstool"],
author="Tully Foote",
author_email="tfoote@osrfoundation.org",
Expand Down
89 changes: 54 additions & 35 deletions src/wstool/cli_common.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,28 @@ def _uris_match(basepath, uri1, uri2):
return False


def _get_svn_version_from_uri(uri):
"""
in case of SVN, we can use the final part of
standard uri as spec version, if it follows canonical SVN layout

:param uri: uri to extract version from
:returns changed_uri: str, version extracted uri
:returns version: str, extracted version
:returns: (None, None), for empty uri or when there is no regex match for version info
"""
if uri is None:
return None, None
match = re.match('(.*/)((tags|branches|trunk)(/.*)*)', uri)
if (match is not None and
len(match.groups()) > 1 and
uri == ''.join(match.groups()[0:2])):
changed_uri = match.groups()[0]
version = match.groups()[1]
return changed_uri, version
return None, None


def _get_status_flags(basepath, elt_dict):
"""
returns a string where each char conveys status information about
Expand All @@ -140,6 +162,13 @@ def _get_status_flags(basepath, elt_dict):
elt_dict['actualversion'] is not None and
elt_dict['specversion'] != elt_dict['actualversion'])):
mflag += 'V'
if ('remote_revision' in elt_dict and
elt_dict['remote_revision'] != '' and
elt_dict['remote_revision'] is not None and
elt_dict['actualversion'] is not None and
'actualversion' in elt_dict and
elt_dict['remote_revision'] != elt_dict['actualversion']):
mflag += 'C'
return mflag


Expand All @@ -158,6 +187,10 @@ 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'],
'uri': line['uri'],
'curr_uri': None,
Expand All @@ -173,46 +206,31 @@ def get_info_table_elements(basepath, entries):
line['specversion'] = line['specversion'][0:12]
if (line['actualversion'] is not None and len(line['actualversion']) > 12):
line['actualversion'] = line['actualversion'][0:12]
if (line['remote_revision'] is not None and len(line['remote_revision']) > 12):
line['remote_revision'] = line['remote_revision'][0:12]

if line['scm'] is not None:

if line['scm'] == 'svn':
# in case of SVN, we can use the final part of
# standard uri as version
uri = line['uri']
version = line['version']
match = re.match('(.*/)((tags|branches|trunk)(/.*)*)', uri)
if match is not None and len(match.groups()) > 1 and uri == ''.join(match.groups()[0:2]):
uri = match.groups()[0]
if (match.groups()[1] is not None and version is None or version.strip() == ''):
version = match.groups()[1]
else:
version = match.groups()[1]
line['uri'] = uri
line['version'] = version
(line['uri'],
line['version']) = _get_svn_version_from_uri(uri=line['uri'])
if line['curr_uri'] is not None:
uri = line['curr_uri']
match = re.match('(.*/)((tags|branches|trunk)(/.*)*)', uri)
if match is not None and len(match.groups()) > 1 and uri == ''.join(match.groups()[0:2]):
uri = match.groups()[0]
if (match.groups()[1] is not None and version is None or version.strip() == ''):
version = match.groups()[1]
else:
version = match.groups()[1]
line['curr_uri'] = uri
line['curr_version'] = version

if (line['curr_version'] is not None and
line['version'] != line['curr_version']):

output_dict['version'] = "%s (%s)" % (line['curr_version'], line['version'])
else:
output_dict['version'] = line['version']
(line['curr_uri'],
line['curr_version_label']) = _get_svn_version_from_uri(
uri=line['curr_uri'])

if line['scm'] in ['git', 'svn', 'hg']:
line['curr_version'] = line['curr_version_label']

if line['curr_version'] is not None:
output_dict['version'] = line['curr_version']
if output_dict['version'] is not None:
if (line['version'] != output_dict['version']):
output_dict['version'] += " (%s)" % (line['version'] or '-')

if (line['specversion'] is not None and
line['specversion'] != '' and
line['actualversion'] != line['specversion']):

output_dict['matching'] = "%s (%s)" % (line['actualversion'], line['specversion'])
else:
output_dict['matching'] = line['actualversion']
Expand Down Expand Up @@ -263,7 +281,7 @@ def get_info_table(basepath, entries, data_only=False, reverse=False, unmanaged=
'uri': "URI (Spec) [http(s)://...]",
'scm': "SCM ",
'localname': "Localname",
'version': "Version-Spec",
'version': "Version (Spec)",
'matching': "UID (Spec)",
'status': "S"}

Expand Down Expand Up @@ -332,7 +350,8 @@ def get_info_list(basepath, line, data_only=False):
'scm': "SCM:",
'localname': "Localname:",
'path': "Path",
'version': "Version-Spec:",
'version': "Spec-Version:",
'curr_version_label': "Current-Version:",
'status': "Status:",
'specversion': "Spec-Revision:",
'actualversion': "Current-Revision:",
Expand All @@ -341,8 +360,8 @@ def get_info_list(basepath, line, data_only=False):
# table design
selected_headers = ['localname', 'path', 'status',
'scm', 'uri', 'curr_uri',
'version', 'specversion', 'actualversion',
'properties']
'version', 'curr_version_label', 'specversion',
'actualversion', 'properties']

line['status'] = _get_status_flags(basepath, line)

Expand Down
7 changes: 6 additions & 1 deletion src/wstool/config_elements.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,7 @@ def get_diff(self, basepath=None):
def get_status(self, basepath=None, untracked=False):
raise NotImplementedError("ConfigElement get_status unimplemented")


def backup(self, backup_path):
if not backup_path:
raise MultiProjectException(
Expand Down Expand Up @@ -397,7 +398,7 @@ def get_path_spec(self):
version=version,
tags=self.get_properties())

def get_versioned_path_spec(self):
def get_versioned_path_spec(self, fetch=False):
"yaml looking up current version"
version = self.version
if version == '':
Expand All @@ -410,6 +411,8 @@ def get_versioned_path_spec(self):
sys.stderr.write("Warning: version '%s' not found for '%s'\n"
% (self.version, self.local_name))
currevision = self._get_vcsc().get_version()
remote_revision = self._get_vcsc().get_remote_version(fetch=fetch)
curr_version = self._get_vcsc().get_current_version_label()
uri = self.uri
curr_uri = self._get_vcsc().get_url()
# uri might be a shorthand notation equivalent to curr_uri
Expand All @@ -420,8 +423,10 @@ def get_versioned_path_spec(self):
scmtype=self.get_vcs_type_name(),
uri=self.uri,
version=version,
curr_version=curr_version,
revision=revision,
currevision=currevision,
remote_revision=remote_revision,
curr_uri=curr_uri,
tags=self.get_properties())

Expand Down
15 changes: 14 additions & 1 deletion src/wstool/config_yaml.py
Original file line number Diff line number Diff line change
Expand Up @@ -183,9 +183,11 @@ def __init__(self,
scmtype=None,
uri=None,
version=None,
curr_version=None,
tags=None,
revision=None,
currevision=None,
remote_revision=None,
path=None,
curr_uri=None):
"""
Expand All @@ -194,6 +196,7 @@ def __init__(self,
:param scmtype: one of __ALLTYPES__
:param uri: uri from config file
:param version: version label from config file (branchname, tagname, sha-id)
:param cur_version: version information label(s) from VCS (branchname, remote, tracking branch)
:param tags: arbirtrary meta-information (used for ROS package indexing)
:param revision: unique id of label stored in version
:param currrevision: unique id of actual version in file system
Expand All @@ -205,10 +208,12 @@ def __init__(self,
self._uri = uri
self._curr_uri = curr_uri
self._version = version
self._curr_version = curr_version
self._scmtype = scmtype
self._tags = tags or []
self._revision = revision
self._currevision = currevision
self._remote_revision = remote_revision

def __str__(self):
return str(self.get_legacy_yaml())
Expand All @@ -231,8 +236,10 @@ def detach_vcs_info(self):
self._scmtype = None
self._uri = None
self._version = None
self._curr_version = None
self._revision = None
self._currevision = None
self._remote_revision = None

def get_legacy_type(self):
"""return one of __ALLTYPES__"""
Expand Down Expand Up @@ -286,12 +293,18 @@ def get_scmtype(self):
def get_version(self):
return self._version

def get_curr_version(self):
return self._curr_version

def get_revision(self):
return self._revision

def get_current_revision(self):
return self._currevision

def get_remote_revision(self):
return self._remote_revision

def get_uri(self):
return self._uri

Expand All @@ -310,7 +323,7 @@ def get_path_spec_from_yaml(yaml_dict):
tags = []
if type(yaml_dict) != dict:
raise MultiProjectException(
"Yaml for each element must be in YAML dict form")
"Yaml for each element must be in YAML dict form: %s " % yaml_dict)
# old syntax:
# - hg: {local-name: common_rosdeps,
# version: common_rosdeps-1.0.2,
Expand Down
8 changes: 7 additions & 1 deletion src/wstool/multiproject_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -993,6 +993,7 @@ def cmd_info(self, target_path, argv, reverse=True, config=None):
x for missing
L for uncommited (local) changes
V for difference in version and/or remote URI
C for difference in local and remote versions

The 'Version-Spec' column shows what tag, branch or revision was given
in the .rosinstall file. The 'UID' column shows the unique ID of the
Expand Down Expand Up @@ -1031,6 +1032,10 @@ def cmd_info(self, target_path, argv, reverse=True, config=None):
"--yaml", dest="yaml", default=False,
help="Shows only version of single entry. Intended for scripting.",
action="store_true")
parser.add_option(
"--fetch", dest="fetch", default=False,
help="When used, retrieves version information from remote (takes longer).",
action="store_true")
parser.add_option(
"-u", "--untracked", dest="untracked",
default=False,
Expand Down Expand Up @@ -1081,7 +1086,8 @@ def cmd_info(self, target_path, argv, reverse=True, config=None):
# this call takes long, as it invokes scms.
outputs = multiproject_cmd.cmd_info(config,
localnames=args,
untracked=options.untracked)
untracked=options.untracked,
fetch=options.fetch)
if args and len(args) == 1:
# if only one element selected, print just one line
print(get_info_list(config.get_base_path(),
Expand Down
28 changes: 20 additions & 8 deletions src/wstool/multiproject_cmd.py
Original file line number Diff line number Diff line change
Expand Up @@ -392,7 +392,7 @@ def cmd_snapshot(config, localnames=None):
return source_aggregate


def cmd_info(config, localnames=None, untracked=False):
def cmd_info(config, localnames=None, untracked=False, fetch=False):
"""This function compares what should be (config_file) with what is
(directories) and returns a list of dictionary giving each local
path and all the state information about it available.
Expand All @@ -403,9 +403,10 @@ class InfoRetriever():
Auxilliary class to perform IO-bound operations in individual threads
"""

def __init__(self, element, path, untracked):
def __init__(self, element, path, untracked, fetch):
self.element = element
self.path = path
self.fetch = fetch
self.untracked = untracked

def do_work(self):
Expand All @@ -415,8 +416,11 @@ def do_work(self):
curr_uri = None
exists = False
version = "" # what is given in config file
curr_version_label = "" # e.g. branchname
remote_revision = "" # UID on remote
display_version = ''
modified = ""
actualversion = "" # revision number of version
currevision = "" # revision number of version
specversion = "" # actual revision number
localname = self.element.get_local_name()
path = self.element.get_path() or localname
Expand All @@ -431,8 +435,15 @@ def do_work(self):
path_spec = self.element.get_path_spec()
version = path_spec.get_version()
else:
path_spec = self.element.get_versioned_path_spec()
path_spec = self.element.get_versioned_path_spec(fetch=fetch)
version = path_spec.get_version()
remote_revision = path_spec.get_remote_revision()
curr_version_label = path_spec.get_curr_version()
if (curr_version_label is not None and
version != curr_version_label):
display_version = curr_version_label
else:
display_version = version
curr_uri = path_spec.get_curr_uri()
status = self.element.get_status(self.path, self.untracked)
if (status is not None and
Expand All @@ -442,9 +453,8 @@ def do_work(self):
if (version is not None and
version.strip() != '' and
(specversion is None or specversion.strip() == '')):

specversion = '"%s"' % version
actualversion = path_spec.get_current_revision()
currevision = path_spec.get_current_revision()
scm = path_spec.get_scmtype()
uri = path_spec.get_uri()
return {'scm': scm,
Expand All @@ -454,8 +464,10 @@ def do_work(self):
'uri': uri,
'curr_uri': curr_uri,
'version': version,
'remote_revision': remote_revision,
'curr_version_label': curr_version_label,
'specversion': specversion,
'actualversion': actualversion,
'actualversion': currevision,
'modified': modified,
'properties': self.element.get_properties()}

Expand All @@ -466,7 +478,7 @@ def do_work(self):
work = DistributedWork(capacity=len(elements), num_threads=-1)
for element in elements:
if element.get_properties() is None or not 'setup-file' in element.get_properties():
work.add_thread(InfoRetriever(element, path, untracked))
work.add_thread(InfoRetriever(element, path, untracked, fetch))
outputs = work.run()

return outputs
Expand Down
Loading