Rev 2303: Add docs for Results, give some members cleaner names in file:///home/mbp/bzr/Work/resultobj/

Martin Pool mbp at sourcefrog.net
Thu Mar 1 04:15:29 GMT 2007


------------------------------------------------------------
revno: 2303
revision-id: mbp at sourcefrog.net-20070301041528-14my1q8v0buynzut
parent: mbp at sourcefrog.net-20070225104133-nd8tyugcozbq1uox
committer: Martin Pool <mbp at sourcefrog.net>
branch nick: resultobj
timestamp: Thu 2007-03-01 15:15:28 +1100
message:
  Add docs for Results, give some members cleaner names
modified:
  bzrlib/branch.py               branch.py-20050309040759-e4baf4e0d046576e
  bzrlib/tests/branch_implementations/test_pull.py test_pull.py-20060410103942-83c35b26657414fc
  bzrlib/tests/branch_implementations/test_push.py test_push.py-20070130153159-fhfap8uoifevg30j-1
=== modified file 'bzrlib/branch.py'
--- a/bzrlib/branch.py	2007-02-25 10:41:33 +0000
+++ b/bzrlib/branch.py	2007-03-01 04:15:28 +0000
@@ -1405,7 +1405,8 @@
             hooks, used when pushing to a master branch.
         """
         result = PullResult()
-        result.source = source
+        result.source_branch = source
+        result.target_branch = self
         source.lock_read()
         try:
             result.old_revno, result.old_revid = self.last_revision_info()
@@ -1418,11 +1419,11 @@
                 self.set_revision_history(source.revision_history())
             result.new_revno, result.new_revid = self.last_revision_info()
             if _hook_master:
-                result.master = _hook_master
-                result.local = self
+                result.master_branch = _hook_master
+                result.local_branch = self
             else:
-                result.master = self
-                result.local = None
+                result.master_branch = self
+                result.local_branch = None
             if _run_hooks:
                 for hook in Branch.hooks['post_pull']:
                     hook(result)
@@ -1450,8 +1451,8 @@
             hooks, used when pushing to a master branch.
         """
         result = PushResult()
-        result.source = self
-        result.target = target
+        result.source_branch = self
+        result.target_branch = target
         target.lock_write()
         try:
             result.old_revno, result.old_revid = target.last_revision_info()
@@ -1464,11 +1465,11 @@
                 target.set_revision_history(self.revision_history())
             result.new_revno, result.new_revid = target.last_revision_info()
             if _hook_master:
-                result.master = _hook_master
-                result.local = target
+                result.master_branch = _hook_master
+                result.local_branch = target
             else:
-                result.master = target
-                result.local = None
+                result.master_branch = target
+                result.local_branch = None
             if _run_hooks:
                 for hook in Branch.hooks['post_push']:
                     hook(result)
@@ -1929,6 +1930,16 @@
 # results of operations
 
 class PullResult(object):
+    """Result of a Branch.pull operation.
+
+    :ivar old_revno: Revision number before pull.
+    :ivar new_revno: Revision number after pull.
+    :ivar old_revid: Tip revision id before pull.
+    :ivar new_revid: Tip revision id after pull.
+    :ivar source_branch: Source (local) branch object.
+    :ivar master_branch: Master branch of the target, or None.
+    :ivar target_branch: Target/destination branch object.
+    """
 
     def __int__(self):
         # DEPRECATED: pull used to return the change in revno
@@ -1936,6 +1947,16 @@
 
 
 class PushResult(object):
+    """Result of a Branch.push operation.
+
+    :ivar old_revno: Revision number before push.
+    :ivar new_revno: Revision number after push.
+    :ivar old_revid: Tip revision id before push.
+    :ivar new_revid: Tip revision id after push.
+    :ivar source_branch: Source branch object.
+    :ivar master_branch: Master branch of the target, or None.
+    :ivar target_branch: Target/destination branch object.
+    """
 
     def __int__(self):
         # DEPRECATED: push used to return the change in revno

=== modified file 'bzrlib/tests/branch_implementations/test_pull.py'
--- a/bzrlib/tests/branch_implementations/test_pull.py	2007-02-23 05:39:35 +0000
+++ b/bzrlib/tests/branch_implementations/test_pull.py	2007-03-01 04:15:28 +0000
@@ -1,4 +1,4 @@
-# Copyright (C) 2004, 2005 Canonical Ltd
+# Copyright (C) 2004, 2005, 2007 Canonical Ltd
 #
 # This program is free software; you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
@@ -92,17 +92,19 @@
         
         The call is logged, as is some state of the two branches.
         """
-        if result.local:
-            local_locked = result.local.is_locked()
-            local_base = result.local.base
+        if result.local_branch:
+            local_locked = result.local_branch.is_locked()
+            local_base = result.local_branch.base
         else:
             local_locked = None
             local_base = None
         self.hook_calls.append(
-            ('post_pull', result.source, local_base, result.master.base, result.old_revno,
+            ('post_pull', result.source_branch, local_base,
+             result.master_branch.base, result.old_revno,
              result.old_revid,
-             result.new_revno, result.new_revid, result.source.is_locked(), local_locked,
-             result.master.is_locked()))
+             result.new_revno, result.new_revid,
+             result.source_branch.is_locked(), local_locked,
+             result.master_branch.is_locked()))
 
     def test_post_pull_empty_history(self):
         target = self.make_branch('target')

=== modified file 'bzrlib/tests/branch_implementations/test_push.py'
--- a/bzrlib/tests/branch_implementations/test_push.py	2007-02-25 10:40:16 +0000
+++ b/bzrlib/tests/branch_implementations/test_push.py	2007-03-01 04:15:28 +0000
@@ -153,17 +153,19 @@
         
         The call is logged, as is some state of the two branches.
         """
-        if result.local:
-            local_locked = result.local.is_locked()
-            local_base = result.local.base
+        if result.local_branch:
+            local_locked = result.local_branch.is_locked()
+            local_base = result.local_branch.base
         else:
             local_locked = None
             local_base = None
         self.hook_calls.append(
-            ('post_push', result.source, local_base, result.master.base,
+            ('post_push', result.source_branch, local_base,
+             result.master_branch.base,
              result.old_revno, result.old_revid,
-             result.new_revno, result.new_revid, result.source.is_locked(), local_locked,
-             result.master.is_locked()))
+             result.new_revno, result.new_revid,
+             result.source_branch.is_locked(), local_locked,
+             result.master_branch.is_locked()))
 
     def test_post_push_empty_history(self):
         target = self.make_branch('target')




More information about the bazaar-commits mailing list