def propertyUpdate(self, filenames): """ Set the keywords property for the supplied filenames. """ # Split up the filenames array into smaller sub-arrays, otherwise # we choke running out of memory due to a really large SCCS # repository like ON while len(filenames): if len(filenames) > 3000: print "partitioning filenames into smaller new_filenames" new_filenames = filenames[:3000] filenames = filenames[3000:] """ Set the keywords property for the supplied filenames. """ subpool = core.svn_pool_create(self.pool) (revision, transaction, root) = self._revisionSetup(subpool, options.userid, "Automated property set") for filename in new_filenames: if isTextFilename(filename): print "property set for ", filename fs.change_node_prop(root, filename, core.SVN_PROP_KEYWORDS, "LastChangedDate LastChangedRevision LastChangedBy HeadURL Id", subpool) fs.change_node_prop(root, filename, core.SVN_PROP_EOL_STYLE, "native", subpool) else: print "skipping property set for ", filename self._commit(revision, subversionTime(time.localtime()), transaction, subpool) core.svn_pool_destroy(subpool)
def write(self, data, uname='', commitmsg='',istext=False): txn = repos.fs_begin_txn_for_commit(self._repo.repos_ptr, self.revno, uname, commitmsg) r = None try: txn_root = fs.txn_root(txn) kind = fs.check_path(txn_root, self.path) if kind == core.svn_node_none: if not _create_file(txn_root, self.path): raise 'attempt to create file, but file creation error: %s'%path pass elif kind == core.svn_node_dir: raise 'attempt to create file, but directory already exists: %s'%self.path if istext: fs.change_node_prop(txn_root, self.path, 'svn:eol-style', 'native') pass handler, baton = fs.apply_textdelta(txn_root, self.path, None, None) delta.svn_txdelta_send_string(data, handler, baton) r = repos.fs_commit_txn(self._repo.repos_ptr, txn) except Exception, a: fs.abort_txn(txn) raise
def add(self, deltas): """ Add the supplied set of deltas to the repository. They will all be added with the same user name, date, and comment. """ # Split up the deltas array into smaller sub-arrays, otherwise # we choke running out of memory due to really large changesets # like the CDDL 2005/06/08 putback in ON that touched every file while len(deltas): if len(deltas) > 1000: print "partitioning deltas into smaller new_deltas" new_deltas = deltas[:1000] deltas = deltas[1000:] # Add all of the directories first, or we will be trying # to cross transactions, which is bad. for delta in new_deltas: self._addDirectories(delta) print "preparing %s version %s (%s) by %s" % (delta.pathname, delta.version, delta.date, delta.author) subpool = core.svn_pool_create(self.pool) (revision, transaction, root) = self._revisionSetup(subpool, new_deltas[0].author, new_deltas[0].comment) for delta in new_deltas: subversionPath = delta.getRepositoryName() kind = fs.check_path(root, subversionPath, subpool) if kind == core.svn_node_none: fs.make_file(root, subversionPath, subpool) elif kind == core.svn_node_dir: raise EnvironmentError(subversionPath + " already present as a directory.") handler, baton = fs.apply_textdelta(root, subversionPath, None, None, subpool) svn.delta.svn_txdelta_send_string(delta.getFileContents(), handler, baton, subpool) if delta.version.isdigit: fs.change_node_prop(root, subversionPath, 'sccs:sid', delta.version, subpool) print "sending ", subversionPath, delta.getDate(), "by", delta.author print "committing version ", print self._commit(revision, delta.getDate(), transaction, subpool) core.svn_pool_destroy(subpool)
def keywordPropertyUpdate(self, files): """ Does the following to text files: 1) Sets svn:keywords property 2) Replace SCCS keywords with SVN equivalents Note that while this will be treated as a separate transaction, the transaction date will be set to the last known date for the given file """ # Break up files into groups in order to avoid # potential "Too many open files" errors thrown when # committing large changesets counter = 0 filesPerCommit = 256 for filename, version in files.iteritems(): if counter%filesPerCommit == 0: if counter > 1: print "committing version ", print self._commit(revision, subversionTime(localtz.localize(datetime.now())), transaction, subpool) core.svn_pool_destroy(subpool) subpool = core.svn_pool_create(self.pool) (revision, transaction, root ) = \ self._revisionSetup(subpool, options.userid, "Automated SCCS keyword -> svn:keyword conversion\n") if isTextFilename(filename): print filename + ":" print " ... Setting svn:keywords property" fs.change_node_prop(root, filename, core.SVN_PROP_KEYWORDS, "LastChangedDate LastChangedRevision LastChangedBy HeadURL Id", subpool) fs.change_node_prop(root, filename, core.SVN_PROP_EOL_STYLE, "native", subpool) oldFileContents = version.getFileContents("-k") newFileContents = keywordSubstitution(oldFileContents) if oldFileContents != newFileContents: print " ... keywords converted" handler, baton = fs.apply_textdelta(root, version.getRepositoryName(), None, None, subpool) svn.delta.svn_txdelta_send_string(newFileContents, handler, baton, subpool) print " ... sending" else: print "skipping ", filename # Note we must unset sccs:sid since it no longer applies fs.change_node_prop(root, filename, 'sccs:sid', None, subpool) counter += 1 # Commit any stragglers print "committing version ", print self._commit(revision, subversionTime(localtz.localize(datetime.now())), transaction, subpool) core.svn_pool_destroy(subpool)