Comment 4 for bug 164450

Revision history for this message
Parth Malwankar (parthm) wrote :

I decided to hack this a bit. I have the following working.

[foo]% bzr tag abc0
Created tag abc0.
[foo]% ~/src/bzr.dev/164450-push-pull-tags/bzr --no-plugins push ../bar
No new revisions to push.
Pushed 1 tags.
[foo]% ~/src/bzr.dev/164450-push-pull-tags/bzr --no-plugins push ../bar
No new revisions to push.
No tags to push.
[foo]%

.. but I am not too familiar with the way push/pull works, so I would
appreciate any help in understanding the existing design.

This is what I put together (push only right now). Updated methods are
branch.BzrBranch._basic_push, branch.BranchPushResult.report, and
tag.BasicTags._reconcile_tags.

Does this approach seem reasonable?
Would a similar approach apply to pull?

[bzrlib]% bzr cdiff -r -3
=== modified file 'bzrlib/branch.py'
--- bzrlib/branch.py 2010-01-12 02:48:41 +0000
+++ bzrlib/branch.py 2010-02-20 04:23:23 +0000
@@ -2328,7 +2328,7 @@
             target.update_revisions(self, stop_revision,
                 overwrite=overwrite, graph=graph)
         if self._push_should_merge_tags():
- result.tag_conflicts = self.tags.merge_to(target.tags,
+ result.tag_conflicts, result.copied_tag_count = self.tags.merge_to(target.tags,
                 overwrite)
         result.new_revno, result.new_revid = target.last_revision_info()
         return result
@@ -2831,6 +2831,10 @@
             note('No new revisions to push.')
         else:
             note('Pushed up to revision %d.' % self.new_revno)
+ if self.copied_tag_count == 0:
+ note('No tags to push.')
+ else:
+ note('Pushed %d tags.' % self.copied_tag_count)
         self._show_tag_conficts(to_file)

=== modified file 'bzrlib/tag.py'
--- bzrlib/tag.py 2009-06-10 03:56:49 +0000
+++ bzrlib/tag.py 2010-02-20 03:44:48 +0000
@@ -208,13 +208,13 @@
         to_tags.branch.lock_write()
         try:
             dest_dict = to_tags.get_tag_dict()
- result, conflicts = self._reconcile_tags(source_dict, dest_dict,
- overwrite)
+ result, conflicts, copied_tag_count = self._reconcile_tags(source_dict,
+ dest_dict, overwrite)
             if result != dest_dict:
                 to_tags._set_tag_dict(result)
         finally:
             to_tags.branch.unlock()
- return conflicts
+ return conflicts, copied_tag_count

     def rename_revisions(self, rename_map):
         """Rename revisions in this tags dictionary.
@@ -241,14 +241,18 @@
         """
         conflicts = []
         result = dict(dest_dict) # copy
+ copied_tag_count = 0
         for name, target in source_dict.items():
- if name not in result or overwrite:
+ name_not_in_result = name not in result
+ if name_not_in_result:
+ copied_tag_count += 1
+ if name_not_in_result or overwrite:
                 result[name] = target
             elif result[name] == target:
                 pass
             else:
                 conflicts.append((name, target, result[name]))
- return result, conflicts
+ return result, conflicts, copied_tag_count

 def _merge_tags_if_possible(from_branch, to_branch):

[bzrlib]%