Пример #1
0
	def default_add(self, field, value):
		(remotes, repos, default) = manifest.read(self.manifest_filename, apply_default=False)
		default[field] = value
		manifest.write(self.manifest_filename, remotes, repos, default)
		self.read_manifest()

		self.output.append('default added: %s=%s' % (field, value))
Пример #2
0
	def remote_add(self, remote, fetch):
		(remotes, repos, default) = manifest.read(self.manifest_filename, apply_default=False)
		if not remotes.has_key(remote):
			remotes[remote] = {'name':remote}
		remotes[remote]['fetch'] = fetch
		manifest.write(self.manifest_filename, remotes, repos, default)
		self.read_manifest()

		self.output.append('remote %s added' % remote)
Пример #3
0
	def read_manifest(self):
		'''Project.read_manifest() -- read the manifest file.'''
		(self.remotes, self.repos) = manifest.read(self.manifest_filename, default_default=RUG_DEFAULT_DEFAULT)
		if not self.bare:
			for path in self.repos:
				abs_path = os.path.abspath(os.path.join(self.dir, path))
				R = self.vcs_class[self.repos[path]['vcs']]
				if R.valid_repo(abs_path):
					self.repos[path]['repo'] = R(abs_path, output_buffer=self.output.spawn(path + ': '))
				else:
					self.repos[path]['repo'] = None
Пример #4
0
	def remove(self, path):
		"""
		Remove a repo from the manifest
		"""

		(remotes, repos, default) = manifest.read(self.manifest_filename, apply_default=False)
		lookup_default = {}
		lookup_default.update(RUG_DEFAULT_DEFAULT)
		lookup_default.update(default)

		if path not in repos:
			raise RugError('unrecognized repo %s' % path)

		del(repos[path])

		manifest.write(self.manifest_filename, remotes, repos, default)
		self.read_manifest()

		self.output.append("%s removed from manifest" % path)
Пример #5
0
	def add(self, path, name=None, remote=None, rev=None, vcs=None, use_sha=None):
		#TODO:handle lists of dirs
		(remotes, repos, default) = manifest.read(self.manifest_filename, apply_default=False)
		lookup_default = {}
		lookup_default.update(RUG_DEFAULT_DEFAULT)
		lookup_default.update(default)

		update_rug_branch = False

		r = self.repos.get(path, None)
		if r is None:
			# Validate inputs
			if name is None:
				raise RugError('new repos must specify a name')
			if remote is None:
				raise RugError('new repos must specify a remote')
			if self.bare:
				if rev is None:
					raise RugError('new repos in bare projects must specify a rev')
				if vcs is None:
					raise RugError('new repos in bare projects must specify a vcs')

		if self.bare:
			#Can't really test/validate anything here since there's no repo
			#Hope the user knows what they're doing

			#Add the repo
			repos[path] = {'path': path}

			revision = rev
		else:
			if r is None:
				#New repository
				#Find vcs if not specified, and create repo object
				abs_path = os.path.join(self.dir, path)
				if vcs is None:
					repo = None
					#TODO: rug needs to take priority here, as rug repos with sub-repos at '.'
					#will look like the sub-repo vcs as well as a rug repo
					#(but not if the path of the sub-repo is '.')
					for (try_vcs, R) in self.vcs_class.items():
						if R.valid_repo(abs_path):
							repo = R(abs_path, output_buffer=self.output.spawn(path + ': '))
							vcs = try_vcs
							break
					if repo is None:
						raise RugError('unrecognized repo %s' % path)
				else:
					repo = self.vcs_class[vcs](abs_path, output_buffer=self.output.spawn(path + ': '))

				#Add the repo
				repos[path] = {'path': path}

				#TODO: we don't know if the remote even exists yet, so can't set up all branches
				#logic elsewhere should be able to handle this possibility (remote & bookmark branches don't exist)
				update_rug_branch = True

				#TODO: should this be required?  If not, what should the default be?
				if use_sha is None:
					use_sha = False
			else:
				#Modify existing repo
				repo = r['repo']

				#TODO: rethink this condition
				if remote is not None:
					update_rug_branch = True

				#If use_sha is not specified, look at existing manifest revision
				if use_sha is None:
					use_sha = repo.valid_sha(r.get('revision', lookup_default['revision']))

			#Get the rev
			if rev is None:
				rev = repo.head()
			else:
				rev = repo.rev_class.cast(repo, rev)
			if use_sha:
				rev = repo.rev_class(repo, rev.get_sha())
			revision = rev.get_short_name()

		#Update repo properties
		for p in ['revision', 'name', 'remote', 'vcs']:
			pval = locals()[p]
			if (pval is not None) and (pval != lookup_default.get(p)):
				repos[path][p] = pval

		#Write the manifest and reload repos
		manifest.write(self.manifest_filename, remotes, repos, default)
		self.read_manifest()

		if not self.bare:
			r = self.repos[path]
			repo = r['repo']
			branches = self.get_branch_names(r)

			#Update rug_index
			repo.update_ref(branches['rug_index'], rev)

			#If this is a new repo, set the rug branch
			if update_rug_branch:
				repo.update_ref(branches['rug'], rev)

		self.output.append("%s added to manifest" % path)