Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
return None
self._type = 'svn'
root = _info(r'^Repository Root: (.+)$')
url = _info(r'^URL: (.+)$')
if not (root and url):
return None
scheme, netloc, path, _, _ = root
root = urlunparse([scheme, root.netloc.split("@")[-1], path,
"", "", ""])
base_path = url.path[len(path):]
return RepositoryInfo(path=root, base_path=base_path,
supports_parent_diffs=True)
if not server_version:
return None
m = re.search(r'[^ ]*/([0-9]+)\.([0-9]+)/[0-9]+ .*$',
server_version, re.M)
if m:
self.p4d_version = int(m.group(1)), int(m.group(2))
else:
# Gracefully bail if we don't get a match
return None
# Now that we know it's Perforce, make sure we have GNU diff
# installed, and error out if we don't.
check_gnu_diff()
return RepositoryInfo(path=repository_path, supports_changesets=True)
return None
bzr_info = execute(['bzr', 'info'], ignore_errors=True)
if 'ERROR: Not a branch:' in bzr_info:
# This is not a branch:
repository_info = None
else:
# This is a branch, let's get its attributes:
branch_match = re.search(self.BRANCH_REGEX, bzr_info, re.MULTILINE)
path = branch_match.group('branch_path')
if path == '.':
path = os.getcwd()
repository_info = RepositoryInfo(
path=path,
base_path='/', # Diffs are always relative to the root.
local_path=path,
supports_parent_diffs=True)
return repository_info
def get_repository_info(self):
"""Determine and return the repository info.
Returns:
rbtools.clients.RepositoryInfo:
The repository info object. If the current working directory does
not correspond to a TFS checkout, this returns ``None``.
"""
rc, path, errors = self._run_helper(['get-collection'],
ignore_errors=True)
if rc == 0:
return RepositoryInfo(path.strip())
else:
return None
if self.debug: cmd_args.append('--debug')
# The users must already exists with matching name in rb
if m['voted_reviewer_users']:
cmd_args.extend([ '--target-people', ','.join(m['voted_reviewer_users']) ])
# Map teams to rb groups, which need to be setup with matching name in rb
if m['voted_reviewer_teams']:
cmd_args.extend([ '--target-groups', ','.join(m['voted_reviewer_teams']) ])
# If we have some reviewers then we can publish
if m['voted_reviewer_users'] or m['voted_reviewer_teams']:
cmd_args.append('--publish')
rbtools.postreview.parse_options(cmd_args)
# Not in a repo so fake up the info
repository_info = RepositoryInfo(
path=repo_url,
base_path="/", # Diffs are always relative to the root.
supports_parent_diffs=False )
# If we end up creating a cookie file, make sure it's only readable by the
# user.
os.umask(0077)
cookie_file = os.path.join(os.environ["HOME"], ".post-review-cookies.txt")
self.rb = ReviewBoardServer(self.server, repository_info, cookie_file)
# Handle the case where /api/ requires authorization (RBCommons).
# This is needed to initialise the object before making API calls.
if not self.rb.check_api_version():
raise CmdError("Unable to log in with the supplied username and password.")
self.rb.login()
elif cpath.exists(new_file) or self.viewtype == 'snapshot':
dl = self._diff_files(old_file, new_file)
else:
logging.error('File %s does not exist or access is denied.',
new_file)
continue
if dl:
diff.append(b''.join(dl))
return {
'diff': b''.join(diff),
}
class ClearCaseRepositoryInfo(RepositoryInfo):
"""A representation of a ClearCase source code repository.
This version knows how to find a matching repository on the server even if
the URLs differ.
"""
def __init__(self, path, base_path, vobstag):
"""Initialize the repsitory info.
Args:
path (unicode):
The path of the repository.
base_path (unicode):
The relative path between the repository root and the working
directory.
return None
workfold = self._run_tf(['workfold', os.getcwd()])
m = re.search('^Collection: (.*)$', workfold, re.MULTILINE)
if not m:
logging.debug('Could not find the collection from "tf workfold"')
return None
# Now that we know it's TFS, make sure we have GNU diff installed,
# and error out if we don't.
check_gnu_diff()
path = unquote(m.group(1))
return RepositoryInfo(path=path, local_path=path)
# Get the repository that the current directory is from
split = execute(['cm', 'ls', self.workspacedir, '--format={8}'],
split_lines=True, ignore_errors=True)
# remove blank lines
split = [x for x in split if x]
m = re.search(r'^rep:(.+)$', split[0], re.M)
if not m:
return None
path = m.group(1)
return RepositoryInfo(path=path,
local_path=path,
supports_changesets=True,
supports_parent_diffs=False)
def __init__(self, path, base_path, vobstag):
"""Initialize the repsitory info.
Args:
path (unicode):
The path of the repository.
base_path (unicode):
The relative path between the repository root and the working
directory.
vobstag (unicode):
The vobstag for the repository.
"""
RepositoryInfo.__init__(self, path, base_path,
supports_parent_diffs=False)
self.vobstag = vobstag