Rev 6522: (jelmer) Add --overwrite-tags option to push and pull. (Jelmer Vernooij) in file:///srv/pqm.bazaar-vcs.org/archives/thelove/bzr/%2Btrunk/
Patch Queue Manager
pqm at pqm.ubuntu.com
Mon Apr 16 11:35:53 UTC 2012
At file:///srv/pqm.bazaar-vcs.org/archives/thelove/bzr/%2Btrunk/
------------------------------------------------------------
revno: 6522 [merge]
revision-id: pqm at pqm.ubuntu.com-20120416113553-1vnossk7c384rp4q
parent: pqm at pqm.ubuntu.com-20120416103050-rbkgxv7kih8y80ca
parent: jelmer at samba.org-20120416110811-0y996ihqy9o2bb1t
committer: Patch Queue Manager <pqm at pqm.ubuntu.com>
branch nick: +trunk
timestamp: Mon 2012-04-16 11:35:53 +0000
message:
(jelmer) Add --overwrite-tags option to push and pull. (Jelmer Vernooij)
modified:
bzrlib/branch.py branch.py-20050309040759-e4baf4e0d046576e
bzrlib/builtins.py builtins.py-20050830033751-fc01482b9ca23183
bzrlib/push.py push.py-20080606021927-5fe39050e8xne9un-1
bzrlib/tests/blackbox/test_pull.py test_pull.py-20051201144907-64959364f629947f
bzrlib/tests/blackbox/test_push.py test_push.py-20060329002750-929af230d5d22663
doc/en/release-notes/bzr-2.6.txt bzr2.6.txt-20120116134316-8w1xxom1c7vcu1t5-1
=== modified file 'bzrlib/branch.py'
--- a/bzrlib/branch.py 2012-03-29 12:27:52 +0000
+++ b/bzrlib/branch.py 2012-04-16 11:08:11 +0000
@@ -3270,6 +3270,15 @@
raise NotImplementedError(self.fetch)
+def _fix_overwrite_type(overwrite):
+ if isinstance(overwrite, bool):
+ if overwrite:
+ return ["history", "tags"]
+ else:
+ return []
+ return overwrite
+
+
class GenericInterBranch(InterBranch):
"""InterBranch implementation that uses public Branch functions."""
@@ -3440,15 +3449,18 @@
result.target_branch = self.target
result.old_revno, result.old_revid = self.target.last_revision_info()
self.source.update_references(self.target)
+ overwrite = _fix_overwrite_type(overwrite)
if result.old_revid != stop_revision:
# We assume that during 'push' this repository is closer than
# the target.
graph = self.source.repository.get_graph(self.target.repository)
- self._update_revisions(stop_revision, overwrite=overwrite,
- graph=graph)
+ self._update_revisions(stop_revision,
+ overwrite=("history" in overwrite),
+ graph=graph)
if self.source._push_should_merge_tags():
result.tag_updates, result.tag_conflicts = (
- self.source.tags.merge_to(self.target.tags, overwrite))
+ self.source.tags.merge_to(
+ self.target.tags, "tags" in overwrite))
result.new_revno, result.new_revid = self.target.last_revision_info()
return result
@@ -3532,13 +3544,16 @@
# -- JRV20090506
result.old_revno, result.old_revid = \
self.target.last_revision_info()
- self._update_revisions(stop_revision, overwrite=overwrite,
+ overwrite = _fix_overwrite_type(overwrite)
+ self._update_revisions(stop_revision,
+ overwrite=("history" in overwrite),
graph=graph)
# TODO: The old revid should be specified when merging tags,
# so a tags implementation that versions tags can only
# pull in the most recent changes. -- JRV20090506
result.tag_updates, result.tag_conflicts = (
- self.source.tags.merge_to(self.target.tags, overwrite,
+ self.source.tags.merge_to(self.target.tags,
+ "tags" in overwrite,
ignore_master=not merge_tags_to_master))
result.new_revno, result.new_revid = self.target.last_revision_info()
if _hook_master:
=== modified file 'bzrlib/builtins.py'
--- a/bzrlib/builtins.py 2012-04-11 02:22:42 +0000
+++ b/bzrlib/builtins.py 2012-04-16 11:08:11 +0000
@@ -1153,7 +1153,9 @@
"the master branch."
),
Option('show-base',
- help="Show base revision text in conflicts.")
+ help="Show base revision text in conflicts."),
+ Option('overwrite-tags',
+ help="Overwrite tags only."),
]
takes_args = ['location?']
encoding_type = 'replace'
@@ -1161,7 +1163,14 @@
def run(self, location=None, remember=None, overwrite=False,
revision=None, verbose=False,
directory=None, local=False,
- show_base=False):
+ show_base=False, overwrite_tags=False):
+
+ if overwrite:
+ overwrite = ["history", "tags"]
+ elif overwrite_tags:
+ overwrite = ["tags"]
+ else:
+ overwrite = []
# FIXME: too much stuff is in the command class
revision_id = None
mergeable = None
@@ -1305,6 +1314,8 @@
Option('no-tree',
help="Don't populate the working tree, even for protocols"
" that support it."),
+ Option('overwrite-tags',
+ help="Overwrite tags only."),
]
takes_args = ['location?']
encoding_type = 'replace'
@@ -1312,9 +1323,17 @@
def run(self, location=None, remember=None, overwrite=False,
create_prefix=False, verbose=False, revision=None,
use_existing_dir=False, directory=None, stacked_on=None,
- stacked=False, strict=None, no_tree=False):
+ stacked=False, strict=None, no_tree=False,
+ overwrite_tags=False):
from bzrlib.push import _show_push_branch
+ if overwrite:
+ overwrite = ["history", "tags"]
+ elif overwrite_tags:
+ overwrite = ["tags"]
+ else:
+ overwrite = []
+
if directory is None:
directory = '.'
# Get the source branch
=== modified file 'bzrlib/push.py'
--- a/bzrlib/push.py 2012-02-14 17:22:37 +0000
+++ b/bzrlib/push.py 2012-04-16 11:08:11 +0000
@@ -68,8 +68,8 @@
:param location: the url of the destination
:param to_file: the output stream
:param verbose: if True, display more output than normal
- :param overwrite: if False, a current branch at the destination may not
- have diverged from the source, otherwise the push fails
+ :param overwrite: list of things to overwrite ("history", "tags")
+ or boolean indicating for everything
:param remember: if True, store the location as the push location for
the source branch
:param stacked_on: the url of the branch, if any, to stack on;
=== modified file 'bzrlib/tests/blackbox/test_pull.py'
--- a/bzrlib/tests/blackbox/test_pull.py 2012-01-18 14:09:19 +0000
+++ b/bzrlib/tests/blackbox/test_pull.py 2012-04-16 11:08:11 +0000
@@ -533,6 +533,23 @@
self.assertEqual(out,
('1 tag(s) updated.\n', ''))
+ def test_overwrite_tags(self):
+ """--overwrite-tags only overwrites tags, not revisions."""
+ from_tree = self.make_branch_and_tree('from')
+ from_tree.branch.tags.set_tag("mytag", "somerevid")
+ to_tree = self.make_branch_and_tree('to')
+ to_tree.branch.tags.set_tag("mytag", "anotherrevid")
+ revid1 = to_tree.commit('my commit')
+ out = self.run_bzr(['pull', '-d', 'to', 'from'], retcode=1)
+ self.assertEquals(out,
+ ('No revisions to pull.\nConflicting tags:\n mytag\n', ''))
+ out = self.run_bzr(['pull', '-d', 'to', '--overwrite-tags', 'from'])
+ self.assertEquals(out, ('1 tag(s) updated.\n', ''))
+
+ self.assertEquals(to_tree.branch.tags.lookup_tag('mytag'),
+ 'somerevid')
+ self.assertEquals(to_tree.branch.last_revision(), revid1)
+
def test_pull_tag_overwrite(self):
"""pulling tags with --overwrite only reports changed tags."""
# create a branch, see that --show-base fails
=== modified file 'bzrlib/tests/blackbox/test_push.py'
--- a/bzrlib/tests/blackbox/test_push.py 2012-01-18 14:09:19 +0000
+++ b/bzrlib/tests/blackbox/test_push.py 2012-04-16 11:08:11 +0000
@@ -613,6 +613,22 @@
self.assertEqual('', out)
self.assertEqual('Created new branch.\n', err)
+ def test_overwrite_tags(self):
+ """--overwrite-tags only overwrites tags, not revisions."""
+ from_tree = self.make_branch_and_tree('from')
+ from_tree.branch.tags.set_tag("mytag", "somerevid")
+ to_tree = self.make_branch_and_tree('to')
+ to_tree.branch.tags.set_tag("mytag", "anotherrevid")
+ revid1 = to_tree.commit('my commit')
+ out = self.run_bzr(['push', '-d', 'from', 'to'])
+ self.assertEquals(out,
+ ('Conflicting tags:\n mytag\n', 'No new revisions to push.\n'))
+ out = self.run_bzr(['push', '-d', 'from', '--overwrite-tags', 'to'])
+ self.assertEquals(out, ('', '1 tag updated.\n'))
+ self.assertEquals(to_tree.branch.tags.lookup_tag('mytag'),
+ 'somerevid')
+ self.assertEquals(to_tree.branch.last_revision(), revid1)
+
class RedirectingMemoryTransport(memory.MemoryTransport):
=== modified file 'doc/en/release-notes/bzr-2.6.txt'
--- a/doc/en/release-notes/bzr-2.6.txt 2012-04-16 02:00:46 +0000
+++ b/doc/en/release-notes/bzr-2.6.txt 2012-04-16 11:08:11 +0000
@@ -20,6 +20,9 @@
.. New commands, options, etc that users may wish to try out.
+* New option ``--overwrite-tags`` for ``bzr pull`` and ``bzr push``.
+ (Jelmer Vernooij, #681792)
+
Improvements
************
More information about the bazaar-commits
mailing list