Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
# installed, and error out if we don't.
check_gnu_diff()
property_lines = execute(
['cleartool', 'lsview', '-full', '-properties', '-cview'],
split_lines=True)
for line in property_lines:
properties = line.split(' ')
if properties[0] == 'Properties:':
# Determine the view type and check if it's supported.
#
# Specifically check if webview was listed in properties
# because webview types also list the 'snapshot'
# entry in properties.
if 'webview' in properties:
raise SCMError('Webviews are not supported. You can use '
'rbt commands only in dynamic or snapshot '
'views.')
if 'dynamic' in properties:
self.viewtype = 'dynamic'
else:
self.viewtype = 'snapshot'
break
# Find current VOB's tag
vobstag = execute(['cleartool', 'describe', '-short', 'vob:.'],
ignore_errors=True).strip()
if 'Error: ' in vobstag:
raise SCMError('Failed to generate diff run rbt inside vob.')
root_path = execute(['cleartool', 'pwv', '-root'],
if not ignore_errors and (rc or has_error):
for record in result:
if 'data' in record:
print(record['data'])
raise SCMError('Failed to execute command: %s\n' % cmd)
return result
elif input_string is not None:
p = subprocess.Popen(cmd, stdin=subprocess.PIPE)
p.communicate(input_string) # Send input, wait, set returncode
if not ignore_errors and p.returncode:
raise SCMError('Failed to execute command: %s\n' % cmd)
return None
else:
result = execute(cmd, ignore_errors=ignore_errors, *args, **kwargs)
return result
``diff`` (:py:class:`bytes`):
The contents of the diff to upload.
``base_commit_id` (:py:class:`unicode`, optional):
The ID of the commit that the change is based on, if available.
This is necessary for some hosting services that don't provide
individual file access.
"""
base = str(revisions['base'])
tip = str(revisions['tip'])
if tip == self.REVISION_WORKING_COPY:
return self._diff_working_copy(base, include_files,
exclude_patterns)
else:
raise SCMError('Posting committed changes is not yet supported '
'for TFS when using the Team Explorer Everywhere '
if getattr(self.options, 'repository_url', None):
command.append(self.options.repository_url)
log = self.svn_log_xml(command)
if log is not None:
try:
root = ElementTree.fromstring(log)
except ValueError as e:
# _convert_symbolic_revision() nominally raises a ValueError to
# indicate any failure to determine the revision number from
# the log entry. Here, we explicitly catch a ValueError from
# ElementTree and raise a generic SCMError so that this
# specific failure to parse the XML log output is
# differentiated from the nominal case.
raise SCMError('Failed to parse svn log - %s.' % e)
logentry = root.find('logentry')
if logentry is not None:
return int(logentry.attrib['revision'])
raise ValueError
if 'webview' in properties:
raise SCMError('Webviews are not supported. You can use '
'rbt commands only in dynamic or snapshot '
'views.')
if 'dynamic' in properties:
self.viewtype = 'dynamic'
else:
self.viewtype = 'snapshot'
break
# Find current VOB's tag
vobstag = execute(['cleartool', 'describe', '-short', 'vob:.'],
ignore_errors=True).strip()
if 'Error: ' in vobstag:
raise SCMError('Failed to generate diff run rbt inside vob.')
root_path = execute(['cleartool', 'pwv', '-root'],
ignore_errors=True).strip()
if 'Error: ' in root_path:
raise SCMError('Failed to generate diff run rbt inside view.')
# From current working directory cut path to VOB. On Windows
# and under cygwin, the VOB tag contains the VOB's path including
# name, e.g. `\new_proj` for a VOB `new_proj` mounted at the root
# of a drive. On Unix, the VOB tag is similar, but with a different
# path separator, e.g. `/vobs/new_proj` for our new_proj VOB mounted
# at `/vobs`.
cwd = os.getcwd()
base_path = cwd[:len(root_path) + len(vobstag)]
return ClearCaseRepositoryInfo(path=base_path,
'base': self.REVISION_BRANCH_BASE,
'tip': revisions[0][len(self.REVISION_BRANCH_PREFIX):],
}
if revisions[0].startswith(self.REVISION_LABEL_PREFIX):
return {
'base': self.REVISION_LABEL_BASE,
'tip': [revisions[0][len(self.REVISION_BRANCH_PREFIX):]],
}
# TODO:
# stream:streamname[@pvob] => review changes in this UCM stream
# (UCM "branch")
# baseline:baseline[@pvob] => review changes between this baseline
# and the working directory
elif n_revs == 2:
if self.viewtype != 'dynamic':
raise SCMError('To generate a diff using multiple revisions, '
'you must use a dynamic view.')
if (revisions[0].startswith(self.REVISION_LABEL_PREFIX) and
revisions[1].startswith(self.REVISION_LABEL_PREFIX)):
return {
'base': self.REVISION_LABEL_BASE,
'tip': [x[len(self.REVISION_BRANCH_PREFIX):]
for x in revisions],
}
# TODO:
# baseline:baseline1[@pvob] baseline:baseline2[@pvob]
# => review changes between these two
# baselines
pass
pairs = []
if (tip == SVNClient.REVISION_WORKING_COPY or
tip.startswith(SVNClient.REVISION_CHANGELIST_PREFIX)):
return ''
command = ['-r', '%s:%s' % (base, tip)]
if getattr(self.options, 'repository_url', None):
command.append(self.options.repository_url)
log = self.svn_log_xml(command)
try:
root = ElementTree.fromstring(log)
except ValueError as e:
raise SCMError('Failed to parse svn log: %s' % e)
# We skip the first commit message, because we want commit messages
# corresponding to the changes that will be included in the diff.
messages = root.findall('.//msg')[1:]
return '\n\n'.join(message.text for message in messages)
The contents of the diff to upload.
``base_commit_id` (:py:class:`unicode`, optional):
The ID of the commit that the change is based on, if available.
This is necessary for some hosting services that don't provide
individual file access.
"""
base = str(revisions['base'])
tip = str(revisions['tip'])
if tip == self.REVISION_WORKING_COPY:
# TODO: support committed revisions
return self._diff_working_copy(base, include_files,
exclude_patterns)
else:
raise SCMError('Posting committed changes is not yet supported '
'for TFS when using the tf.exe wrapper.')
self.viewtype = 'dynamic'
else:
self.viewtype = 'snapshot'
break
# Find current VOB's tag
vobstag = execute(['cleartool', 'describe', '-short', 'vob:.'],
ignore_errors=True).strip()
if 'Error: ' in vobstag:
raise SCMError('Failed to generate diff run rbt inside vob.')
root_path = execute(['cleartool', 'pwv', '-root'],
ignore_errors=True).strip()
if 'Error: ' in root_path:
raise SCMError('Failed to generate diff run rbt inside view.')
# From current working directory cut path to VOB. On Windows
# and under cygwin, the VOB tag contains the VOB's path including
# name, e.g. `\new_proj` for a VOB `new_proj` mounted at the root
# of a drive. On Unix, the VOB tag is similar, but with a different
# path separator, e.g. `/vobs/new_proj` for our new_proj VOB mounted
# at `/vobs`.
cwd = os.getcwd()
base_path = cwd[:len(root_path) + len(vobstag)]
return ClearCaseRepositoryInfo(path=base_path,
base_path=base_path,
vobstag=vobstag)