Merge lp:~jelmer/bzr/overwrite-tags into lp:bzr

Proposed by Jelmer Vernooij
Status: Merged
Approved by: Jelmer Vernooij
Approved revision: no longer in the source branch.
Merged at revision: 6522
Proposed branch: lp:~jelmer/bzr/overwrite-tags
Merge into: lp:bzr
Diff against target: 202 lines (+80/-10)
6 files modified
bzrlib/branch.py (+20/-5)
bzrlib/builtins.py (+22/-3)
bzrlib/push.py (+2/-2)
bzrlib/tests/blackbox/test_pull.py (+17/-0)
bzrlib/tests/blackbox/test_push.py (+16/-0)
doc/en/release-notes/bzr-2.6.txt (+3/-0)
To merge this branch: bzr merge lp:~jelmer/bzr/overwrite-tags
Reviewer Review Type Date Requested Status
bzr-core Pending
Review via email: mp+94551@code.launchpad.net

Commit message

Add --overwrite-tags option to push and pull.

Description of the change

Add --overwrite-tags argument to "bzr push" and "bzr pull".

I'm not entirely sure about the API change. I don't really want to end up with overwrite-history, overwrite-tags, overwrite-references, etc so using a tuple seemed reasonable. Users can still specify a boolean if they want to overwrite everything. Thoughts?

(There is also a merge proposal open for lp:bzr/2.5, this is a resubmission against lp:bzr)

To post a comment you must log in.
Revision history for this message
Vincent Ladeuil (vila) wrote :

I'm not sure we understood each other here :-/

What I objected about was the addition of the --overwrite-tags parameter, all the rest is ~fine by me (I'm still wondering about _fix_overwrite_type being private but needed by the plugins but that's a minor concern).

The rationale here is that we already know that the long term solution is to have versioned tags. Once we get there, --overwrite-tags will have to be deprecated/deleted as it will be replaced by some moral equivalent of 'bzr resolve --take-other'.

Therefore, I'd rather implement this behavior behind a config option (that can still be used from the command line with -O) to address the edge case and not add a parameter that we'll have to remove. The option can be documented to explain that it's a temporary one that will eventually get removed once tags are versioned.

Revision history for this message
Jelmer Vernooij (jelmer) wrote :

Am 13/03/12 09:10, schrieb Vincent Ladeuil:
> I'm not sure we understood each other here :-/
>
> What I objected about was the addition of the --overwrite-tags parameter, all the rest is ~fine by me (I'm still wondering about _fix_overwrite_type being private but needed by the plugins but that's a minor concern).
>
> The rationale here is that we already know that the long term solution is to have versioned tags. Once we get there, --overwrite-tags will have to be deprecated/deleted as it will be replaced by some moral equivalent of 'bzr resolve --take-other'.
Even when we have versioned tags I still think it would be useful to
overwrite tags in some cases.
> Therefore, I'd rather implement this behavior behind a config option (that can still be used from the command line with -O) to address the edge case and not add a parameter that we'll have to remove. The option can be documented to explain that it's a temporary one that will eventually get removed once tags are versioned.
There are always going to be formats in bzr that don't support versioned tags, so I don't think we'd ever be able to delete it. Having it as a configuration option just makes it less explicit in the API I think.

Cheers,

jelmer

Revision history for this message
Vincent Ladeuil (vila) wrote :

> There are always going to be formats in bzr that don't support versioned tags,
> so I don't think we'd ever be able to delete it. Having it as a configuration
> option just makes it less explicit in the API I think.

Right, that's exactly where we disagree :) Tag conflicts occur rarely so only a few people are concerned by this feature and I argue that these people will be equally well served by a config option. *But* even the option and the command line parameter fall short about addressing the issue I faced for the 2.3.2 bzr release where lp:bzr/2.3 needed to have its tags overwritten but was (still is and will be) unreachable (without asking a losa which is cheating).

How about landing this stuff behind a config option and *then* discuss about adding the parameter to have some progress ? That would even allow landing in 2.5 in this case as this will not break compatibility (assuming you update the foreign plugins accordingly).

Revision history for this message
Jelmer Vernooij (jelmer) wrote :

Am 13/03/12 10:15, schrieb Vincent Ladeuil:
>> There are always going to be formats in bzr that don't support versioned tags,
>> so I don't think we'd ever be able to delete it. Having it as a configuration
>> option just makes it less explicit in the API I think.
> Right, that's exactly where we disagree :) Tag conflicts occur rarely so only a few people are concerned by this feature and I argue that these people will be equally well served by a config option. *But* even the option and the command line parameter fall short about addressing the issue I faced for the 2.3.2 bzr release where lp:bzr/2.3 needed to have its tags overwritten but was (still is and will be) unreachable (without asking a losa which is cheating).
It's come up a few times (the emacs folks have asked about it too), so I
would argue it's not unheard of. I don't really see the harm in adding a
option for "bzr push" / "bzr pull" and a command-line option is a lot
more discoverable than a configuration option. This also doesn't really
seem appropriate as a configuration option since you wouldn't really
want to set this option in e.g. branch.conf any more than you would want
to set 'overwrite = True'.

We can't directly push to lp: bzr/2.3 so I don't understand how that is
relevant to the discussion about 'bzr push --overwrite-tags' ?
>
> How about landing this stuff behind a config option and *then* discuss about adding the parameter to have some progress ? That would even allow landing in 2.5 in this case as this will not break compatibility (assuming you update the foreign plugins accordingly).
Doing this will break compatibility no more or less than my patch does,
in that anything that doesn't support it will ignore it and anything
that does support it will.

I don't really want to update the foreign plugins for this now, as it
means rolling three new releases and getting those packaged, etc.

Cheers,

Jelmer

Revision history for this message
Vincent Ladeuil (vila) wrote :

> It's come up a few times (the emacs folks have asked about it too), so I
> would argue it's not unheard of. I don't really see the harm in adding a
> option for "bzr push" / "bzr pull" and a command-line option is a lot
> more discoverable than a configuration option.

The fact that it's more exposed means more work associated with removing it
which is my point. Yes, some people need this option, I agree with that or I
wouldn't search for a way to land the associated feature :)

> This also doesn't really
> seem appropriate as a configuration option since you wouldn't really
> want to set this option in e.g. branch.conf any more than you would want
> to set 'overwrite = True'.

I disagree with that, if I maintaining an official branch mirrored to
apublic website I very well want to set this option locally.

>
> We can't directly push to lp: bzr/2.3 so I don't understand how that is
> relevant to the discussion about 'bzr push --overwrite-tags' ?

This is precicely what versioned tags could address :)

> >
> > How about landing this stuff behind a config option and *then* discuss about
> adding the parameter to have some progress ? That would even allow landing in
> 2.5 in this case as this will not break compatibility (assuming you update the
> foreign plugins accordingly).
> Doing this will break compatibility no more or less than my patch does,
> in that anything that doesn't support it will ignore it and anything
> that does support it will.

It won't break the command-line compatibility which is exactly what I'm
arguing against.

Revision history for this message
Vincent Ladeuil (vila) wrote :

> > We can't directly push to lp: bzr/2.3 so I don't understand how that is
> > relevant to the discussion about 'bzr push --overwrite-tags' ?
>
> This is precicely what versioned tags could address :)

I.e. since --overwrite-tags does not address what versioned tags should
address I'd rather not add a parameter that only partially address the use
case.

Revision history for this message
Jelmer Vernooij (jelmer) wrote :

Am 13/03/12 10:40, schrieb Vincent Ladeuil:
>> It's come up a few times (the emacs folks have asked about it too), so I
>> would argue it's not unheard of. I don't really see the harm in adding a
>> option for "bzr push" / "bzr pull" and a command-line option is a lot
>> more discoverable than a configuration option.
> The fact that it's more exposed means more work associated with removing it
> which is my point. Yes, some people need this option, I agree with that or I
> wouldn't search for a way to land the associated feature :)
I don't think we'll ever want to remove this option if we add it. There
are plenty of formats that don't support versioned tags and some of them
aren't going to go away (e.g. git, 2a, etc).
>
>> This also doesn't really
>> seem appropriate as a configuration option since you wouldn't really
>> want to set this option in e.g. branch.conf any more than you would want
>> to set 'overwrite = True'.
> I disagree with that, if I maintaining an official branch mirrored to
> apublic website I very well want to set this option locally.
By that reasoning "overwrite" should be a configuration option rather
than a command-line option too.... ?
>>> How about landing this stuff behind a config option and *then* discuss about
>> adding the parameter to have some progress ? That would even allow landing in
>> 2.5 in this case as this will not break compatibility (assuming you update the
>> foreign plugins accordingly).
>> Doing this will break compatibility no more or less than my patch does,
>> in that anything that doesn't support it will ignore it and anything
>> that does support it will.
> It won't break the command-line compatibility which is exactly what I'm
> arguing against.
How is adding a new command-line option breaking command-line compatibility?

If you mean that we'll break compatibility if we remove this
command-line option later then I think that a configuration option is no
better. In fact, in the case of a configuration option we'll *silently*
ignore what the user specified, which is probably a lot more confusing.

Cheers,

Jelmer

Revision history for this message
Jelmer Vernooij (jelmer) wrote :

Marking as approved, since the same branch is now approved for landing in 2.5.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'bzrlib/branch.py'
--- bzrlib/branch.py 2012-03-29 12:27:52 +0000
+++ bzrlib/branch.py 2012-04-16 11:12:22 +0000
@@ -3270,6 +3270,15 @@
3270 raise NotImplementedError(self.fetch)3270 raise NotImplementedError(self.fetch)
32713271
32723272
3273def _fix_overwrite_type(overwrite):
3274 if isinstance(overwrite, bool):
3275 if overwrite:
3276 return ["history", "tags"]
3277 else:
3278 return []
3279 return overwrite
3280
3281
3273class GenericInterBranch(InterBranch):3282class GenericInterBranch(InterBranch):
3274 """InterBranch implementation that uses public Branch functions."""3283 """InterBranch implementation that uses public Branch functions."""
32753284
@@ -3440,15 +3449,18 @@
3440 result.target_branch = self.target3449 result.target_branch = self.target
3441 result.old_revno, result.old_revid = self.target.last_revision_info()3450 result.old_revno, result.old_revid = self.target.last_revision_info()
3442 self.source.update_references(self.target)3451 self.source.update_references(self.target)
3452 overwrite = _fix_overwrite_type(overwrite)
3443 if result.old_revid != stop_revision:3453 if result.old_revid != stop_revision:
3444 # We assume that during 'push' this repository is closer than3454 # We assume that during 'push' this repository is closer than
3445 # the target.3455 # the target.
3446 graph = self.source.repository.get_graph(self.target.repository)3456 graph = self.source.repository.get_graph(self.target.repository)
3447 self._update_revisions(stop_revision, overwrite=overwrite,3457 self._update_revisions(stop_revision,
3448 graph=graph)3458 overwrite=("history" in overwrite),
3459 graph=graph)
3449 if self.source._push_should_merge_tags():3460 if self.source._push_should_merge_tags():
3450 result.tag_updates, result.tag_conflicts = (3461 result.tag_updates, result.tag_conflicts = (
3451 self.source.tags.merge_to(self.target.tags, overwrite))3462 self.source.tags.merge_to(
3463 self.target.tags, "tags" in overwrite))
3452 result.new_revno, result.new_revid = self.target.last_revision_info()3464 result.new_revno, result.new_revid = self.target.last_revision_info()
3453 return result3465 return result
34543466
@@ -3532,13 +3544,16 @@
3532 # -- JRV200905063544 # -- JRV20090506
3533 result.old_revno, result.old_revid = \3545 result.old_revno, result.old_revid = \
3534 self.target.last_revision_info()3546 self.target.last_revision_info()
3535 self._update_revisions(stop_revision, overwrite=overwrite,3547 overwrite = _fix_overwrite_type(overwrite)
3548 self._update_revisions(stop_revision,
3549 overwrite=("history" in overwrite),
3536 graph=graph)3550 graph=graph)
3537 # TODO: The old revid should be specified when merging tags, 3551 # TODO: The old revid should be specified when merging tags,
3538 # so a tags implementation that versions tags can only 3552 # so a tags implementation that versions tags can only
3539 # pull in the most recent changes. -- JRV200905063553 # pull in the most recent changes. -- JRV20090506
3540 result.tag_updates, result.tag_conflicts = (3554 result.tag_updates, result.tag_conflicts = (
3541 self.source.tags.merge_to(self.target.tags, overwrite,3555 self.source.tags.merge_to(self.target.tags,
3556 "tags" in overwrite,
3542 ignore_master=not merge_tags_to_master))3557 ignore_master=not merge_tags_to_master))
3543 result.new_revno, result.new_revid = self.target.last_revision_info()3558 result.new_revno, result.new_revid = self.target.last_revision_info()
3544 if _hook_master:3559 if _hook_master:
35453560
=== modified file 'bzrlib/builtins.py'
--- bzrlib/builtins.py 2012-04-11 02:22:42 +0000
+++ bzrlib/builtins.py 2012-04-16 11:12:22 +0000
@@ -1153,7 +1153,9 @@
1153 "the master branch."1153 "the master branch."
1154 ),1154 ),
1155 Option('show-base',1155 Option('show-base',
1156 help="Show base revision text in conflicts.")1156 help="Show base revision text in conflicts."),
1157 Option('overwrite-tags',
1158 help="Overwrite tags only."),
1157 ]1159 ]
1158 takes_args = ['location?']1160 takes_args = ['location?']
1159 encoding_type = 'replace'1161 encoding_type = 'replace'
@@ -1161,7 +1163,14 @@
1161 def run(self, location=None, remember=None, overwrite=False,1163 def run(self, location=None, remember=None, overwrite=False,
1162 revision=None, verbose=False,1164 revision=None, verbose=False,
1163 directory=None, local=False,1165 directory=None, local=False,
1164 show_base=False):1166 show_base=False, overwrite_tags=False):
1167
1168 if overwrite:
1169 overwrite = ["history", "tags"]
1170 elif overwrite_tags:
1171 overwrite = ["tags"]
1172 else:
1173 overwrite = []
1165 # FIXME: too much stuff is in the command class1174 # FIXME: too much stuff is in the command class
1166 revision_id = None1175 revision_id = None
1167 mergeable = None1176 mergeable = None
@@ -1305,6 +1314,8 @@
1305 Option('no-tree',1314 Option('no-tree',
1306 help="Don't populate the working tree, even for protocols"1315 help="Don't populate the working tree, even for protocols"
1307 " that support it."),1316 " that support it."),
1317 Option('overwrite-tags',
1318 help="Overwrite tags only."),
1308 ]1319 ]
1309 takes_args = ['location?']1320 takes_args = ['location?']
1310 encoding_type = 'replace'1321 encoding_type = 'replace'
@@ -1312,9 +1323,17 @@
1312 def run(self, location=None, remember=None, overwrite=False,1323 def run(self, location=None, remember=None, overwrite=False,
1313 create_prefix=False, verbose=False, revision=None,1324 create_prefix=False, verbose=False, revision=None,
1314 use_existing_dir=False, directory=None, stacked_on=None,1325 use_existing_dir=False, directory=None, stacked_on=None,
1315 stacked=False, strict=None, no_tree=False):1326 stacked=False, strict=None, no_tree=False,
1327 overwrite_tags=False):
1316 from bzrlib.push import _show_push_branch1328 from bzrlib.push import _show_push_branch
13171329
1330 if overwrite:
1331 overwrite = ["history", "tags"]
1332 elif overwrite_tags:
1333 overwrite = ["tags"]
1334 else:
1335 overwrite = []
1336
1318 if directory is None:1337 if directory is None:
1319 directory = '.'1338 directory = '.'
1320 # Get the source branch1339 # Get the source branch
13211340
=== modified file 'bzrlib/push.py'
--- bzrlib/push.py 2012-02-14 17:22:37 +0000
+++ bzrlib/push.py 2012-04-16 11:12:22 +0000
@@ -68,8 +68,8 @@
68 :param location: the url of the destination68 :param location: the url of the destination
69 :param to_file: the output stream69 :param to_file: the output stream
70 :param verbose: if True, display more output than normal70 :param verbose: if True, display more output than normal
71 :param overwrite: if False, a current branch at the destination may not71 :param overwrite: list of things to overwrite ("history", "tags")
72 have diverged from the source, otherwise the push fails72 or boolean indicating for everything
73 :param remember: if True, store the location as the push location for73 :param remember: if True, store the location as the push location for
74 the source branch74 the source branch
75 :param stacked_on: the url of the branch, if any, to stack on;75 :param stacked_on: the url of the branch, if any, to stack on;
7676
=== modified file 'bzrlib/tests/blackbox/test_pull.py'
--- bzrlib/tests/blackbox/test_pull.py 2012-01-18 14:09:19 +0000
+++ bzrlib/tests/blackbox/test_pull.py 2012-04-16 11:12:22 +0000
@@ -533,6 +533,23 @@
533 self.assertEqual(out,533 self.assertEqual(out,
534 ('1 tag(s) updated.\n', ''))534 ('1 tag(s) updated.\n', ''))
535535
536 def test_overwrite_tags(self):
537 """--overwrite-tags only overwrites tags, not revisions."""
538 from_tree = self.make_branch_and_tree('from')
539 from_tree.branch.tags.set_tag("mytag", "somerevid")
540 to_tree = self.make_branch_and_tree('to')
541 to_tree.branch.tags.set_tag("mytag", "anotherrevid")
542 revid1 = to_tree.commit('my commit')
543 out = self.run_bzr(['pull', '-d', 'to', 'from'], retcode=1)
544 self.assertEquals(out,
545 ('No revisions to pull.\nConflicting tags:\n mytag\n', ''))
546 out = self.run_bzr(['pull', '-d', 'to', '--overwrite-tags', 'from'])
547 self.assertEquals(out, ('1 tag(s) updated.\n', ''))
548
549 self.assertEquals(to_tree.branch.tags.lookup_tag('mytag'),
550 'somerevid')
551 self.assertEquals(to_tree.branch.last_revision(), revid1)
552
536 def test_pull_tag_overwrite(self):553 def test_pull_tag_overwrite(self):
537 """pulling tags with --overwrite only reports changed tags."""554 """pulling tags with --overwrite only reports changed tags."""
538 # create a branch, see that --show-base fails555 # create a branch, see that --show-base fails
539556
=== modified file 'bzrlib/tests/blackbox/test_push.py'
--- bzrlib/tests/blackbox/test_push.py 2012-01-18 14:09:19 +0000
+++ bzrlib/tests/blackbox/test_push.py 2012-04-16 11:12:22 +0000
@@ -613,6 +613,22 @@
613 self.assertEqual('', out)613 self.assertEqual('', out)
614 self.assertEqual('Created new branch.\n', err)614 self.assertEqual('Created new branch.\n', err)
615615
616 def test_overwrite_tags(self):
617 """--overwrite-tags only overwrites tags, not revisions."""
618 from_tree = self.make_branch_and_tree('from')
619 from_tree.branch.tags.set_tag("mytag", "somerevid")
620 to_tree = self.make_branch_and_tree('to')
621 to_tree.branch.tags.set_tag("mytag", "anotherrevid")
622 revid1 = to_tree.commit('my commit')
623 out = self.run_bzr(['push', '-d', 'from', 'to'])
624 self.assertEquals(out,
625 ('Conflicting tags:\n mytag\n', 'No new revisions to push.\n'))
626 out = self.run_bzr(['push', '-d', 'from', '--overwrite-tags', 'to'])
627 self.assertEquals(out, ('', '1 tag updated.\n'))
628 self.assertEquals(to_tree.branch.tags.lookup_tag('mytag'),
629 'somerevid')
630 self.assertEquals(to_tree.branch.last_revision(), revid1)
631
616632
617class RedirectingMemoryTransport(memory.MemoryTransport):633class RedirectingMemoryTransport(memory.MemoryTransport):
618634
619635
=== modified file 'doc/en/release-notes/bzr-2.6.txt'
--- doc/en/release-notes/bzr-2.6.txt 2012-04-16 02:00:46 +0000
+++ doc/en/release-notes/bzr-2.6.txt 2012-04-16 11:12:22 +0000
@@ -20,6 +20,9 @@
2020
21.. New commands, options, etc that users may wish to try out.21.. New commands, options, etc that users may wish to try out.
2222
23* New option ``--overwrite-tags`` for ``bzr pull`` and ``bzr push``.
24 (Jelmer Vernooij, #681792)
25
23Improvements26Improvements
24************27************
2528