[PATCH] mq:qpush and qpop with serial index

Chris Mason mason at suse.com
Tue Sep 13 06:40:38 CDT 2005


On Tue, 13 Sep 2005 11:22:35 +0800
Xiaofeng Ling <xiaofeng.ling at intel.com> wrote:

> Chris
>      This patch made I can use both index number and patch name. Using
> index number is so much convient for me. The index number can be
> gotten by hg series -v

I like this a lot.

> 
> hg qpush 4
> hg qpop  3
> 
> diff -r 2031b0e8d6e6 contrib/mq
> --- a/contrib/mq	Sun Sep 11 18:08:20 2005
> +++ b/contrib/mq	Tue Sep 13 11:16:23 2005
> @@ -287,6 +287,13 @@
>           return None
> 
>       def push(self, repo, patch=None, force=False, list=False):
> +        if patch and re.match("\d", patch):

re.match("\d") will match any string that starts with a number.  I'd
rather see this:

if patch and not isfile(os.path.join(self.path, patch)):
    try:
        sno = int(patch)
    except (ValueError, OverflowError):
        (error about file not found)

This way if someone want a patch named 1, things will still work.

> 
> 
> If you think it is ok, I also like to implement like hg qpush +3

+3 would be nice too.  While you're there, could you put this into a
lookup function inside the queue class?  That way we won't have to
duplicate the checks in both push and pop.  I wouldn't mind regex
support on the name matching either:

hg qpush reiserfs.* # push all the way up to the last patch starting
with reiser hg qpop mm-.* # pop all the way up to the first patch
starting with mm

etc (of course, I don't expect you to code that if you don't think
you'll use it).

-chris


More information about the Mercurial mailing list