[PATCH 2 of 2] push: warn after pushing draft changesets with tags

Nathan Goldbaum nathan12343 at gmail.com
Fri Mar 11 10:44:00 EST 2016


On Fri, Mar 11, 2016 at 8:42 AM, Pierre-Yves David <
pierre-yves.david at ens-lyon.org> wrote:

>
>
> On 03/11/2016 02:47 AM, Nathan Goldbaum wrote:
>
>> # HG changeset patch
>> # User Nathan Goldbaum <ngoldbau at illinois.edu>
>> # Date 1457664319 21600
>> #      Thu Mar 10 20:45:19 2016 -0600
>> # Node ID fa56f5ded2ef6c9b0a0bec00f42c252c51e2f094
>> # Parent  4cbd3237f1e5b4f442c4ee527d977ace2f6ce619
>> push: warn after pushing draft changesets with tags
>>
>
> Can we get a bit more details here? What is the rational, some exemple
> output, etc.
>
> More comment below.
>
>
> diff -r 4cbd3237f1e5 -r fa56f5ded2ef mercurial/commands.py
>> --- a/mercurial/commands.py     Thu Mar 10 17:31:38 2016 -0600
>> +++ b/mercurial/commands.py     Thu Mar 10 20:45:19 2016 -0600
>> @@ -5846,6 +5846,19 @@ def push(ui, repo, dest=None, **opts):
>>           elif not result and pushop.bkresult:
>>               result = 2
>>
>> +    # warn if any draft changesets with tags were pushed
>> +    if not result:
>> +        for rev in pushop.outgoing.missing:
>> +            ctx = repo[rev]
>> +            tag_names = ctx.tags()
>> +            if 'tip' in tag_names:
>> +                tag_names.remove('tip')
>> +            if tag_names and ctx.phase() == phases.draft:
>>
>
> be safe of check of "mutable" of "not public())
>
> +                tag_names = ["'" + t + "'" for t in tag_names]
>> +                tag_names = ' and '.join(tag_names)
>>
>
> Revset would be more efficient here, you are looking for:
>
>   repo.revs("(%ln - public()) and tagged()", pushop.outgoing.missing)
>
> +                ui.warn(_('pushing draft changeset tagged %s '
>> +                          'to a non-publishing repository\n') %
>> tag_names)
>>
>
> a) You are running this -after- the push. so it should be
>
>   "pushed draft …"
>
> b) Also, don't put all the name on a single message. This will give
> massively gigantic line in pathological case. We have two options here:
>
>   * one line per tags
>   * print the first couple and mention how many other there is. (cf remote
> head warning on push for exemple)
>
> c) We can probably have a more compact message.
>
>   pushed tag "foobar" as draft
>
> (a bit less precise more likely to be read.
>
> "draft" should be ready to be "secret" when applicable. Or maybe we should
> use "mutable"
>
> d) should we put a hint about how to publish it and repush?
>
> +
>>       return result
>>
>>   @command('recover', [])
>> diff -r 4cbd3237f1e5 -r fa56f5ded2ef tests/test-hardlinks.t
>> --- a/tests/test-hardlinks.t    Thu Mar 10 17:31:38 2016 -0600
>> +++ b/tests/test-hardlinks.t    Thu Mar 10 20:45:19 2016 -0600
>> @@ -213,6 +213,7 @@ r4 has hardlinks in the working dir (not
>>     2 r4/.hg/cache/branch2-served
>>     2 r4/.hg/cache/rbc-names-v1
>>     2 r4/.hg/cache/rbc-revs-v1
>> +  2 r4/.hg/cache/tags2-visible
>>     2 r4/.hg/dirstate
>>     2 r4/.hg/hgrc
>>     2 r4/.hg/last-message.txt
>> @@ -249,6 +250,7 @@ Update back to revision 11 in r4 should
>>     2 r4/.hg/cache/branch2-served
>>     2 r4/.hg/cache/rbc-names-v1
>>     2 r4/.hg/cache/rbc-revs-v1
>> +  2 r4/.hg/cache/tags2-visible
>>     1 r4/.hg/dirstate
>>     2 r4/.hg/hgrc
>>     2 r4/.hg/last-message.txt
>>
>
>
> Why is this test affected?


I'm not sure, let's see if it still happens after I apply your suggestions.

Thank you for the careful review.

-Nathan


>
>
> diff -r 4cbd3237f1e5 -r fa56f5ded2ef tests/test-push-warn.t
>> --- a/tests/test-push-warn.t    Thu Mar 10 17:31:38 2016 -0600
>> +++ b/tests/test-push-warn.t    Thu Mar 10 20:45:19 2016 -0600
>> @@ -88,6 +88,23 @@ Specifying a revset that evaluates to nu
>>     adding file changes
>>     added 2 changesets with 1 changes to 1 files
>>
>> +Warn about pushing a draft, tagged changeset to a non-publishing
>> repository
>> +
>> +  $ echo "[phases]" >> ../a/.hg/hgrc
>> +  $ echo "publish = False" >> ../a/.hg/hgrc
>> +  $ echo "foobar" > t5
>> +  $ hg add t5
>> +  $ hg commit -m "5"
>> +  $ hg tag tag-name
>> +  $ hg push ../a
>> +  pushing to ../a
>> +  searching for changes
>> +  adding changesets
>> +  adding manifests
>> +  adding file changes
>> +  added 2 changesets with 2 changes to 2 files
>> +  pushing draft changeset tagged 'tag-name' to a non-publishing
>> repository
>> +
>>     $ cd ..
>>
>>     $ hg init c
>>
>
> --
> Pierre-Yves David
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.mercurial-scm.org/pipermail/mercurial-devel/attachments/20160311/767d025a/attachment.html>


More information about the Mercurial-devel mailing list