Rev 3393: (jam) Fix RemoteRepository.get_parent_map() when server is pre 1.2 in file:///home/pqm/archives/thelove/bzr/%2Btrunk/

Canonical.com Patch Queue Manager pqm at pqm.ubuntu.com
Wed Apr 30 17:18:20 BST 2008


At file:///home/pqm/archives/thelove/bzr/%2Btrunk/

------------------------------------------------------------
revno: 3393
revision-id:pqm at pqm.ubuntu.com-20080430161812-ns7wh4cab7ovfnsy
parent: pqm at pqm.ubuntu.com-20080430065440-1l8693padc4f7uho
parent: john at arbash-meinel.com-20080429200228-ubbv2h0sqtrt0tsi
committer: Canonical.com Patch Queue Manager <pqm at pqm.ubuntu.com>
branch nick: +trunk
timestamp: Wed 2008-04-30 17:18:12 +0100
message:
  (jam) Fix RemoteRepository.get_parent_map() when server is pre 1.2
  	(bug #214894)
modified:
  NEWS                           NEWS-20050323055033-4e00b5db738777ff
  bzrlib/remote.py               remote.py-20060720103555-yeeg2x51vn0rbtdp-1
    ------------------------------------------------------------
    revno: 3389.1.1
    revision-id:john at arbash-meinel.com-20080429200228-ubbv2h0sqtrt0tsi
    parent: pqm at pqm.ubuntu.com-20080429014232-4b86ax5pwynnf11i
    committer: John Arbash Meinel <john at arbash-meinel.com>
    branch nick: remote_get_parent_map_214894
    timestamp: Tue 2008-04-29 15:02:28 -0500
    message:
      Fix bug #214894. Fix RemoteRepository.get_parent_map() when server is <v1.2
      
      When connecting to a server that is <v1.2, the get_parent_map() code falls back
      to using get_revision_graph(). However, for nodes with no parents, get_revision_graph()
      returns an empty tuple, while get_parent_map expects (NULL_REVISION,).
      In get_parent_map() an empty tuple means the node is a ghost.
      
      This caused problems pushing Branch5 branches, because it would check the revision history
      and consider the first commit to be a ghost. Which meant it was excluded from the history.
      And then len(revision_history) was always 1 shorter than the expected value.
    modified:
      NEWS                           NEWS-20050323055033-4e00b5db738777ff
      bzrlib/remote.py               remote.py-20060720103555-yeeg2x51vn0rbtdp-1
=== modified file 'NEWS'
--- a/NEWS	2008-04-30 06:54:40 +0000
+++ b/NEWS	2008-04-30 16:18:12 +0000
@@ -50,6 +50,11 @@
     * Fix error about "attempt to add line-delta in non-delta knit".
       (Andrew Bennetts, #217701)
 
+    * Pushing a branch in "dirstate" format (Branch5) over bzr+ssh would break
+      if the remote server was < version 1.2. This was due to a bug in the
+      RemoteRepository.get_parent_map() fallback code.
+      (John Arbash Meinel, #214894)
+
     * Set SO_REUSEADDR on server sockets of ``bzr serve`` to avoid problems
       rebinding the socket when starting the server a second time.
       (John Arbash Meinel, Martin Pool, #164288)

=== modified file 'bzrlib/remote.py'
--- a/bzrlib/remote.py	2008-04-21 05:51:56 +0000
+++ b/bzrlib/remote.py	2008-04-29 20:02:28 +0000
@@ -823,7 +823,21 @@
             # :- its because we're working with a deprecated server anyway, and
             # the user will almost certainly have seen a warning about the
             # server version already.
-            return self.get_revision_graph()
+            rg = self.get_revision_graph()
+            # There is an api discrepency between get_parent_map and
+            # get_revision_graph. Specifically, a "key:()" pair in
+            # get_revision_graph just means a node has no parents. For
+            # "get_parent_map" it means the node is a ghost. So fix up the
+            # graph to correct this.
+            #   https://bugs.launchpad.net/bzr/+bug/214894
+            # There is one other "bug" which is that ghosts in
+            # get_revision_graph() are not returned at all. But we won't worry
+            # about that for now.
+            for node_id, parent_ids in rg.iteritems():
+                if parent_ids == ():
+                    rg[node_id] = (NULL_REVISION,)
+            rg[NULL_REVISION] = ()
+            return rg
 
         keys = set(keys)
         if NULL_REVISION in keys:




More information about the bazaar-commits mailing list