[PATCH 5 of 5] mq: allow to qpop/push with a dirty working copy (issue2780)

Patrick Mézard pmezard at gmail.com
Sat May 7 12:42:05 CDT 2011


Le 06/05/11 18:58, Idan Kamara a écrit :
> # HG changeset patch
> # User Idan Kamara <idankk86 at gmail.com>
> # Date 1304700946 -10800
> # Node ID 8189f68e1f457eeefddfde425c01e4bcb2e9d27d
> # Parent  b73eaf4c918e1d0269efa925a451d140fa783ddb
> mq: allow to qpop/push with a dirty working copy (issue2780)
> 
> It's safe to do so if the sets of changed files in the
> working copy and patches are disjoint.

I would mention that:

  hg qpush --exact

Now updates with uncommitted changes before trying to patch.
 
> diff -r b73eaf4c918e -r 8189f68e1f45 hgext/mq.py
> --- a/hgext/mq.py	Fri May 06 19:03:45 2011 +0300
> +++ b/hgext/mq.py	Fri May 06 19:55:46 2011 +0300
> @@ -49,6 +49,7 @@
>  from mercurial import repair, extensions, url, error
>  from mercurial import patch as patchmod
>  import os, sys, re, errno, shutil
> +import itertools
>  
>  commands.norepo += " qclone"
>  
> @@ -844,13 +845,16 @@
>                  inclsubs.append(s)
>          return inclsubs
>  
> +    def localchangesfound(self, refresh=True):
> +        if refresh:
> +            raise util.Abort(_("local changes found, refresh first"))
> +        else:
> +            raise util.Abort(_("local changes found"))
> +
>      def check_localchanges(self, repo, force=False, refresh=True):
>          m, a, r, d = repo.status()[:4]
>          if (m or a or r or d) and not force:
> -            if refresh:
> -                raise util.Abort(_("local changes found, refresh first"))
> -            else:
> -                raise util.Abort(_("local changes found"))
> +            self.localchangesfound(refresh)
>          return m, a, r, d
>  
>      _reserved = ('series', 'status', 'guards', '.', '..')
> @@ -1127,8 +1131,6 @@
>              if start == len(self.series):
>                  self.ui.warn(_('patch series already fully applied\n'))
>                  return 1
> -            if not force:
> -                self.check_localchanges(repo, refresh=self.applied)
>  
>              if exact:
>                  if move:
> @@ -1167,6 +1169,18 @@
>                  end = self.series.index(patch, start) + 1
>  
>              s = self.series[start:end]
> +
> +            if not force:
> +                wcfiles = set(itertools.chain(*repo.status()[:4]))

I am not thrilled by importing itertools only to use chain(). mpm may have another opinion.

Also, can you test the qpush case with uncommitted changes (and not an empty patch)?

--
Patrick Mézard


More information about the Mercurial-devel mailing list