[PATCH 3 of 9 V2] push: refuse to push obsolete changeset

Augie Fackler raf at durin42.com
Fri Jul 6 20:05:05 CDT 2012


On Jul 6, 2012, at 1:54 PM, pierre-yves.david at logilab.fr wrote:

> # HG changeset patch
> # User Pierre-Yves David <pierre-yves.david at logilab.fr>
> # Date 1341595623 -7200
> # Node ID 92f00b11481cd4fc34f820bc8474302c23f24420
> # Parent  8d5c67b786a245ecb7b5e656c5a59766349c0ad8
> push: refuse to push obsolete changeset
> 
> This is a first version. Simple but not very efficient.
> 
> Note that this changeset introduce the "obsolete" word in the UI.
> 
> diff --git a/mercurial/localrepo.py b/mercurial/localrepo.py
> --- a/mercurial/localrepo.py
> +++ b/mercurial/localrepo.py
> @@ -1730,10 +1730,18 @@ class localrepository(repo.repository):
>                     scmutil.nochangesfound(self.ui, outgoing.excluded)
>                     ret = None
>                 else:
>                     # something to push
>                     if not force:
> +                        # if self.obsstore == False --> no obsolete
> +                        # then, save the iteration
> +                        if self.obsstore:
> +                            msg = "push includes an obsolete changeset: %s!"

I still think you need to do the _ here rather than below, otherwise the i18n string finding tool won't work. I'm not 100% sure about that though.

> +                            for node in outgoing.missing:
> +                                ctx = self[node]
> +                                if ctx.obsolete():
> +                                    raise util.Abort(_(msg) % ctx)
>                         discovery.checkheads(self, remote, outgoing,
>                                              remoteheads, newbranch,
>                                              bool(inc))
> 
>                     # create a changegroup from local
> diff --git a/tests/test-obsolete.t b/tests/test-obsolete.t
> --- a/tests/test-obsolete.t
> +++ b/tests/test-obsolete.t
> @@ -169,14 +169,20 @@ Try to pull markers
> 
>   $ hg init tmpd
>   $ hg -R tmpb push tmpd
>   pushing to tmpd
>   searching for changes
> +  abort: push includes an obsolete changeset: cdbce2fbb163!
> +  [255]
> +  $ hg -R tmpd debugobsolete
> +  $ hg -R tmpb push tmpd --rev 5601fb93a350 --rev 245bde4270cd
> +  pushing to tmpd
> +  searching for changes
>   adding changesets
>   adding manifests
>   adding file changes
> -  added 6 changesets with 6 changes to 6 files (+3 heads)
> +  added 4 changesets with 4 changes to 4 files (+1 heads)
>   $ hg -R tmpd debugobsolete
>   ca819180edb99ed25ceafb3e9584ac287e240b00 1337133713371337133713371337133713371337 0 {'date': '1338 0', 'user': 'test'}
>   cdbce2fbb16313928851e97e0d85413f3f7eb77f ca819180edb99ed25ceafb3e9584ac287e240b00 0 {'date': '1337 0', 'user': 'test'}
>   245bde4270cd1072a27757984f9cda8ba26f08ca cdbce2fbb16313928851e97e0d85413f3f7eb77f 0 {'date': '56 12', 'user': 'test'}
>   1337133713371337133713371337133713371337 5601fb93a350734d935195fee37f4054c529ff39 0 {'date': '1339 0', 'user': 'test'}
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel at selenic.com
> http://selenic.com/mailman/listinfo/mercurial-devel



More information about the Mercurial-devel mailing list