Merge upstream.
[jelmer/subvertpy.git] / checkout.py
index 99d06afb6dcbcf414e0596a34ccf411cfe19fcbd..931ba0cc5ea8c7b22eca323232e5506d3c756ae2 100644 (file)
@@ -13,6 +13,7 @@
 # You should have received a copy of the GNU General Public License
 # along with this program; if not, write to the Free Software
 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+"""Checkouts and working trees (working copies)."""
 
 from bzrlib.branch import PullResult
 from bzrlib.bzrdir import BzrDirFormat, BzrDir
@@ -30,9 +31,10 @@ from bzrlib.workingtree import WorkingTree, WorkingTreeFormat
 
 from branch import SvnBranch
 from convert import SvnConverter
-from repository import (SvnRepository, escape_svn_path, SVN_PROP_BZR_MERGE,
+from repository import (SvnRepository, SVN_PROP_BZR_MERGE,
                         SVN_PROP_SVK_MERGE, SVN_PROP_BZR_FILEIDS, 
                         revision_id_to_svk_feature) 
+from revids import escape_svn_path
 from scheme import BranchingScheme
 from transport import (SvnRaTransport, svn_config, bzr_to_svn_url, 
                        _create_auth_baton) 
@@ -56,8 +58,7 @@ class WorkingTreeInconsistent(BzrError):
 
 
 class SvnWorkingTree(WorkingTree):
-    """Implementation of WorkingTree that uses a Subversion 
-    Working Copy for storage."""
+    """WorkingTree implementation that uses a Subversion Working Copy for storage."""
     def __init__(self, bzrdir, local_path, branch):
         self._format = SvnWorkingTreeFormat()
         self.basedir = local_path
@@ -224,6 +225,7 @@ class SvnWorkingTree(WorkingTree):
         (_, rp) = self.branch.repository.scheme.unprefix(path)
         entry = self.base_tree.id_map[rp]
         assert entry[0] is not None
+        assert isinstance(entry[0], str), "fileid %r for %r is not a string" % (entry[0], path)
         return entry
 
     def read_working_inventory(self):
@@ -303,6 +305,7 @@ class SvnWorkingTree(WorkingTree):
             if id is None:
                 mutter('no id for %r' % entry.url)
                 return
+            assert revid is None or isinstance(revid, str), "%r is not a string" % revid
             assert isinstance(id, str), "%r is not a string" % id
 
             # First handle directory itself
@@ -350,8 +353,7 @@ class SvnWorkingTree(WorkingTree):
             self.base_tree = RevisionTree(self, Inventory(), revid)
             return
 
-        (bp, rev) = self.branch.repository.parse_revision_id(revid)
-        assert bp == self.branch.branch_path
+        rev = self.branch.lookup_revision_id(revid)
         self.base_revnum = rev
         self.base_revid = revid
         self.base_tree = SvnBasisTree(self)
@@ -363,7 +365,7 @@ class SvnWorkingTree(WorkingTree):
         def update_settings(wc, path):
             id = newrevtree.inventory.path2id(path)
             mutter("Updating settings for %r" % id)
-            (_, revnum) = self.branch.repository.parse_revision_id(
+            revnum = self.branch.lookup_revision_id(
                     newrevtree.inventory[id].revision)
 
             svn.wc.process_committed2(self.abspath(path).rstrip("/"), wc, 
@@ -488,7 +490,7 @@ class SvnWorkingTree(WorkingTree):
             stop_revision = self.branch.last_revision()
         rev = svn.core.svn_opt_revision_t()
         rev.kind = svn.core.svn_opt_revision_number
-        rev.value.number = self.branch.repository.parse_revision_id(stop_revision)[1]
+        rev.value.number = self.branch.lookup_revision_id(stop_revision)
         fetched = svn.client.update(self.basedir, rev, True, self.client_ctx)
         self.base_revid = self.branch.repository.generate_revision_id(fetched, self.branch.branch_path)
         result.new_revid = self.branch.generate_revision_id(fetched)
@@ -510,6 +512,7 @@ class SvnWorkingTree(WorkingTree):
             if new_entries.has_key(path):
                 del new_entries[path]
         else:
+            assert isinstance(id, str)
             new_entries[path] = id
         committed = self.branch.repository.branchprop_list.get_property(
                 self.branch.branch_path, 
@@ -523,25 +526,23 @@ class SvnWorkingTree(WorkingTree):
 
     def _get_new_file_ids(self, wc):
         committed = self.branch.repository.branchprop_list.get_property(
-                self.branch.branch_path, 
-                self.base_revnum, 
+                self.branch.branch_path, self.base_revnum, 
                 SVN_PROP_BZR_FILEIDS, "")
         existing = svn.wc.prop_get(SVN_PROP_BZR_FILEIDS, self.basedir, wc)
         if existing is None:
             return {}
         else:
-            return dict(map(lambda x: x.split("\t"), existing[len(committed):].splitlines()))
+            return dict(map(lambda x: str(x).split("\t"), 
+                existing[len(committed):].splitlines()))
 
     def _get_bzr_merges(self):
         return self.branch.repository.branchprop_list.get_property(
-                self.branch.branch_path, 
-                self.base_revnum, 
+                self.branch.branch_path, self.base_revnum, 
                 SVN_PROP_BZR_MERGE, "")
 
     def _get_svk_merges(self):
         return self.branch.repository.branchprop_list.get_property(
-                self.branch.branch_path, 
-                self.base_revnum, 
+                self.branch.branch_path, self.base_revnum, 
                 SVN_PROP_SVK_MERGE, "")
 
     def set_pending_merges(self, merges):
@@ -598,6 +599,7 @@ class SvnWorkingTree(WorkingTree):
 
 
 class SvnWorkingTreeFormat(WorkingTreeFormat):
+    """Subversion working copy format."""
     def get_format_description(self):
         return "Subversion Working Copy"
 
@@ -635,7 +637,7 @@ class SvnCheckout(BzrDir):
     def clone(self, path, revision_id=None, force_new_repo=False):
         raise NotImplementedError(self.clone)
 
-    def open_workingtree(self, _unsupported=False):
+    def open_workingtree(self, _unsupported=False, recommend_upgrade=False):
         return SvnWorkingTree(self, self.local_path, self.open_branch())
 
     def sprout(self, url, revision_id=None, force_new_repo=False,