git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Catalin Marinas <catalin.marinas@gmail.com>
To: "Karl Hasselström" <kha@treskal.com>
Cc: git@vger.kernel.org
Subject: Re: [StGit PATCH] Add the --merged option to goto
Date: Wed, 25 Mar 2009 10:24:13 +0000	[thread overview]
Message-ID: <b0943d9e0903250324j9ed0ed9k2d97cbacba6a7801@mail.gmail.com> (raw)
In-Reply-To: <20090325090541.GA24889@diana.vm.bytemark.co.uk>

2009/3/25 Karl Hasselström <kha@treskal.com>:
> On 2009-03-24 15:40:10 +0000, Catalin Marinas wrote:
>> Whatever is in the index after the check_merged() function doesn't
>> correspond to any tree so it would need to be re-read.
>
> It does correspond to _some_ tree, but as we have no particular reason
> to expect that it might be a tree that we're going to need again
> immediately, we can set temp_index_tree to None to force re-reading,
> rather than pay the cost of write_tree.

Yes, that's what I meant by "doesn't correspond to any tree".

BTW, why don't we keep the tree information directly in the Index
object? Since this object is modified only via its own interface, it
can do all the checks and avoid the managing of temp_index_tree in the
Transaction object.

>> +    def check_merged(self, patches):
>> +        """Return a subset of patches already merged."""
>> +        merged = []
>> +        self.temp_index.read_tree(self.stack.head.data.tree)
>> +        # The self.temp_index is modified by apply_treediff() so force
>> +        # read_tree() the next time merge() is used.
>> +        self.temp_index_tree = None
>> +        for pn in reversed(patches):
>> +            # check whether patch changes can be reversed in the current index
>> +            cd = self.patches[pn].data
>> +            if cd.is_nochange():
>> +                continue
>> +            try:
>> +                self.temp_index.apply_treediff(cd.tree, cd.parent.data.tree,
>> +                                               quiet = True)
>> +                merged.append(pn)
>> +            except git.MergeException:
>> +                pass
>> +        return merged
>
> Some points here:
>
>  1. Check if temp_index_tree already contains the tree you want
>     instead of doing read_tree unconditionally. That is, change
>
>       self.temp_index.read_tree(self.stack.head.data.tree)
>
>     to
>
>       if self.stack.head.data.tree != self.temp_index_tree:
>           self.temp_index.read_tree(self.stack.head.data.tree)
>           self.temp_index_tree = self.stack.head.data.tree
>
>  2. If apply_treediff fails (raises MergeException), the index wasn't
>     modified at all (but I guess you knew that, since your code
>     relies on that fact), so there's no reason to set temp_index_tree
>     to None in that case. So in order to not clear temp_index_tree
>     unnecessarily in case none of the patches reverse-apply (a case I
>     personally encounter frequently, since I leave the -m flag on all
>     the time), move
>
>       self.temp_index_tree = None
>
>     to just after (or just before) "merged.append(pn)".

Yes. But it may be even better to do this in Index.
Index.apply_treediff() would set the tree to None and read_tree or
write_tree would set it to the corresponding tree.

>  3. Why are empty patches considered not merged?

They would be reported as empty anyway and in general you don't submit
empty patches for upstream merging.

-- 
Catalin

  reply	other threads:[~2009-03-25 10:26 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-03-20 16:15 [StGit PATCH] Add the --merged option to goto Catalin Marinas
2009-03-23  8:45 ` Karl Hasselström
2009-03-23 16:33   ` Catalin Marinas
2009-03-24 13:16     ` Karl Hasselström
2009-03-24 15:40       ` Catalin Marinas
2009-03-25  9:05         ` Karl Hasselström
2009-03-25 10:24           ` Catalin Marinas [this message]
2009-03-26 11:15             ` Karl Hasselström
2009-03-30 16:01               ` Catalin Marinas
2009-03-31  7:27                 ` Karl Hasselström

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=b0943d9e0903250324j9ed0ed9k2d97cbacba6a7801@mail.gmail.com \
    --to=catalin.marinas@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=kha@treskal.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).