コード例 #1
0
ファイル: tags.py プロジェクト: breezy-team/breezy-svn
 def delete_tag(self, tag_name):
     path = self.branch.layout.get_tag_path(tag_name, self.branch.project)
     parent = urlutils.dirname(path)
     conn = self.repository.svn_transport.get_connection(parent)
     try:
         if conn.check_path(
                 urlutils.basename(path),
                 self.repository.get_latest_revnum()) != subvertpy.NODE_DIR:
             raise bzr_errors.NoSuchTag(tag_name)
         ci = svn_errors.convert_svn_error(conn.get_commit_editor)(
             self._revprops("Remove tag %s" % tag_name.encode("utf-8"),
                            {tag_name: ""}))
         try:
             root = ci.open_root()
             root.delete_entry(urlutils.basename(path))
             root.close()
         except:
             ci.abort()
             raise
         ci.close()
         # FIXME: This shouldn't have to remove the entire cache, just update it
         self.repository._clear_cached_state()
     finally:
         assert not conn.busy
         self.repository.svn_transport.add_connection(conn)
コード例 #2
0
ファイル: tags.py プロジェクト: breezy-team/breezy-svn
 def set_tag(self, tag_name, tag_target):
     """Set a new tag in a Subversion repository."""
     path = self.branch.layout.get_tag_path(tag_name, self.branch.project)
     parent = urlutils.dirname(path)
     try:
         (from_uuid, from_bp,
          from_revnum), mapping = self.repository.lookup_bzr_revision_id(
              tag_target, project=self.branch.project)
     except bzr_errors.NoSuchRevision:
         mutter("not setting tag %s; unknown revision %s", tag_name,
                tag_target)
         if GhostTagsNotSupported is not None:
             raise GhostTagsNotSupported(self.branch._format)
         return
     self._ensure_tag_parent_exists(parent)
     try:
         current_from_foreign_revid = self._lookup_tag_revmeta(
             path).metarev.get_foreign_revid()
         deletefirst = True
     except KeyError:
         current_from_foreign_revid = None
         deletefirst = False
     if current_from_foreign_revid == (from_uuid, from_bp, from_revnum):
         # Already present
         return
     mutter("setting tag %s from %r (deletefirst: %r)", path,
            (from_uuid, from_bp, from_revnum), deletefirst)
     conn = self.repository.svn_transport.get_connection(parent)
     try:
         with svn_errors.convert_svn_error(
                 conn.get_commit_editor)(self._revprops(
                     "Add tag %s" % tag_name.encode("utf-8"),
                     {tag_name.encode("utf-8"): tag_target})) as ci:
             root = ci.open_root()
             if deletefirst:
                 root.delete_entry(urlutils.basename(path))
             tag_dir = root.add_directory(
                 urlutils.basename(path),
                 urlutils.join(self.repository.base, from_bp), from_revnum)
             tag_dir.close()
             root.close()
         # FIXME: This shouldn't have to remove the entire cache, just update it
         self.repository._clear_cached_state()
     finally:
         self.repository.svn_transport.add_connection(conn)
コード例 #3
0
 def test_create_anonymous_lightweight_checkout(self):
     """A lightweight checkout from a readonly branch should succeed."""
     tree_a = self.make_branch_and_tree('a')
     rev_id = tree_a.commit('put some content in the branch')
     # open the branch via a readonly transport
     url = self.get_readonly_url(urlutils.basename(tree_a.branch.base))
     t = transport.get_transport_from_url(url)
     if not tree_a.branch.controldir._format.supports_transport(t):
         raise tests.TestNotApplicable("format does not support transport")
     source_branch = _mod_branch.Branch.open(url)
     # sanity check that the test will be valid
     self.assertRaises((errors.LockError, errors.TransportNotPossible),
                       source_branch.lock_write)
     checkout = source_branch.create_checkout('c', lightweight=True)
     self.assertEqual(rev_id, checkout.last_revision())
コード例 #4
0
 def _build_lp_push_suggestion(self, master_url):
     try:
         from breezy.plugins.launchpad import account
     except ImportError:
         # yes, ImportError is possible with bzr.exe,
         # because user has option to not install launchpad plugin at all
         return ''
     from breezy.plugins.qbrz.lib.util import launchpad_project_from_url
     user_name = account.get_lp_login()
     project_name = launchpad_project_from_url(master_url)
     branch_name = urlutils.basename(self.branch.base)
     if user_name and project_name and branch_name:
         return "lp:~%s/%s/%s" % (user_name, project_name, branch_name)
     else:
         return ''
コード例 #5
0
    def stat(self, path, revnum):
        if revnum is None:
            revnum = self.get_latest_revnum()
        branch_path, revid = self._get_revid(revnum)
        tree = self.branch.repository.revision_tree(revid)
        tree_path = path[len(branch_path):].strip("/")
        if not tree.is_versioned(tree_path):
            return None
        ret = {"name": urlutils.basename(path)}
        if tree.kind(tree_path) == "directory":
            ret["kind"] = subvertpy.NODE_DIR
            ret["size"] = 0
        else:
            ret["kind"] = subvertpy.NODE_FILE
            ret["size"] = tree.get_file_size(tree_path)
        ret["has-props"] = True
        ret["created-rev"] = 0  # FIXME
        ret["created-date"] = ""  # FIXME
        ret["last-author"] = ""  # FIXME

        return ret
コード例 #6
0
 def _calculate_package_name(self, recipe_location, package):
     """Calculate the directory name that should be used while debuilding."""
     recipe_name = urlutils.basename(recipe_location)
     if recipe_name.endswith(".recipe"):
         recipe_name = recipe_name[:-len(".recipe")]
     return package or recipe_name
コード例 #7
0
ファイル: standard.py プロジェクト: jelmer/breezy-svn
    def get_tag_name(self, path, project=u""):
        """Determine the tag name from a tag path.

        :param path: Path inside the repository.
        """
        return urlutils.basename(path).strip(u"/")
コード例 #8
0
ファイル: standard.py プロジェクト: jelmer/breezy-svn
 def get_branch_name(self, path, project=""):
     return urlutils.basename(path).strip("/")
コード例 #9
0
ファイル: push.py プロジェクト: breezy-team/breezy-svn
def create_branch_with_hidden_commit(repository, branch_path, revid,
                                     set_metadata=True, deletefirst=False):
    """Create a new branch using a simple "svn cp" operation.

    :param repository: Repository in which to create the branch.
    :param branch_path: Branch path
    :param revid: Revision id to keep as tip.
    :param deletefirst: Whether to delete an existing branch at this location
        first.
    :return: Revision id that was pushed and the related foreign revision id.
    """
    revprops = {properties.PROP_REVISION_LOG: "Create new branch."}
    if revid == NULL_REVISION:
        old_fileprops = {}
        fileprops = {}
        mapping = repository.get_mapping()
        from_url = None
        from_revnum = -1
    else:
        revmeta, mapping = repository._get_revmeta(revid)
        old_fileprops = revmeta.get_fileprops()
        fileprops = dict(old_fileprops.items())
        from_url = url_join_unescaped_path(repository.base,
            revmeta.metarev.branch_path)
        from_revnum = revmeta.metarev.revnum
    if set_metadata:
        if not mapping.supports_hidden:
            raise AssertionError("mapping format %r doesn't support hidden" %
                mapping)
        to_url = urlutils.join(repository.base, branch_path)
        config = SvnBranchStack(to_url, repository.uuid)
        (set_custom_revprops,
            set_custom_fileprops) = repository._properties_to_set(mapping, config)
        if set_custom_revprops:
            mapping.export_hidden_revprops(branch_path, revprops)
            if (not set_custom_fileprops and
                not repository.svn_transport.has_capability("log-revprops")):
                # Tell clients about first approximate use of revision
                # properties
                mapping.export_revprop_redirect(
                    repository.get_latest_revnum()+1, fileprops)
        if set_custom_fileprops:
            mapping.export_hidden_fileprops(fileprops)
    parent = urlutils.dirname(branch_path)

    bp_parts = branch_path.split("/")
    existing_bp_parts = check_dirs_exist(repository.svn_transport, bp_parts, -1)
    if len(bp_parts) not in (len(existing_bp_parts), len(existing_bp_parts)+1):
        raise MissingPrefix("/".join(bp_parts), "/".join(existing_bp_parts))

    if deletefirst is None:
        deletefirst = (bp_parts == existing_bp_parts)

    foreign_revid = [repository.uuid, branch_path]

    def done(revno, *args):
        foreign_revid.append(revno)

    conn = repository.svn_transport.get_connection(parent)
    try:
        with convert_svn_error(conn.get_commit_editor)(revprops, done) as ci:
            root = ci.open_root()
            if deletefirst:
                try:
                    root.delete_entry(urlutils.basename(branch_path))
                except SubversionException as e:
                    if e.args[1] == ERR_FS_ROOT_DIR:
                        raise ChangesRootLHSHistory()
                    raise
            branch_dir = root.add_directory(
                urlutils.basename(branch_path), from_url, from_revnum)
            for k, (ov, nv) in properties.diff(fileprops, old_fileprops).items():
                branch_dir.change_prop(k, nv)
            branch_dir.close()
            root.close()
        repository._cache_add_new_revision(foreign_revid[2], revid, None)
        return revid, (tuple(foreign_revid), mapping)
    finally:
        repository.svn_transport.add_connection(conn)
コード例 #10
0
 def _build_generic_push_suggestion(self, master_url):
     master_parent = urlutils.dirname(master_url)
     branch_name = urlutils.basename(self.branch.base)
     return urlutils.join(master_parent, branch_name)
コード例 #11
0
 def readonly_repository(self, repo):
     relpath = urlutils.basename(repo.controldir.user_url.rstrip('/'))
     return ControlDir.open_from_transport(
         self.get_readonly_transport(relpath)).open_repository()
コード例 #12
0
def keyword_id(*args):
    """basename <space> revno <space> date <space> author"""
    return "%s %s %s %s" % (urlutils.basename(
        keyword_url(*args)), keyword_rev(*args), keyword_date(*args),
                            keyword_author(*args))