git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [StGit PATCH] Add the --merged option to goto

From
Karl Hasselström <kha@treskal.com>
Date
Mar 23, 2009, 08:45 UTC
Message-ID
<20090323084507.GA6447@diana.vm.bytemark.co.uk>
In-Reply-To
<20090320161233.28989.82497.stgit@pc1117.cambridge.arm.com>
On 2009-03-20 16:15:45 +0000, Catalin Marinas wrote:
Show 16 quoted lines
> This patch adds support for checking which patches were already
> merged upstream. This checking is done by trying to reverse-apply
> the patches in the index before pushing them onto the stack. The
> trivial merge cases in Index.merge() are ignored when performing
> this operation otherwise the results could be wrong (e.g. a patch
> adding a hunk and a subsequent patch canceling the previous change
> would both be considered merged).
>
> Signed-off-by: Catalin Marinas <catalin.marinas@gmail.com>
> ---
>
> This is in preparation for the updating of the push command where we
> have this functionality (I think we had it for goto as well but was
> lost with the update to stgit.lib). Test cases with --merged are
> already done for the push command, so I haven't added any for goto
> (but I'll push this patch only after push is updated).
Looks good, except for a few things:
Show 9 quoted lines
> @@ -732,7 +732,7 @@ class Index(RunWithEnv):
>          # to use --binary.
>          self.apply(self.__repository.diff_tree(tree1, tree2, ['--full-index']),
>                     quiet)
> -    def merge(self, base, ours, theirs, current = None):
> +    def merge(self, base, ours, theirs, current = None, check_trivial = True):
>          """Use the index (and only the index) to do a 3-way merge of the
>          L{Tree}s C{base}, C{ours} and C{theirs}. The merge will either
>          succeed (in which case the first half of the return value is
Please update the documentation with your new option. :-)
Show 17 quoted lines
> @@ -752,12 +752,13 @@ class Index(RunWithEnv):
>          assert current == None or isinstance(current, Tree)
>  
>          # Take care of the really trivial cases.
> -        if base == ours:
> -            return (theirs, current)
> -        if base == theirs:
> -            return (ours, current)
> -        if ours == theirs:
> -            return (ours, current)
> +        if check_trivial:
> +            if base == ours:
> +                return (theirs, current)
> +            if base == theirs:
> +                return (ours, current)
> +            if ours == theirs:
> +                return (ours, current)
Uh, what? What's the point of not doing this unconditionally?
Show 10 quoted lines
> @@ -379,3 +385,25 @@ class StackTransaction(object):
>          assert set(self.unapplied + self.hidden) == set(unapplied + hidden)
>          self.unapplied = unapplied
>          self.hidden = hidden
> +
> +    def check_merged(self, patches):
> +        """Return a subset of patches already merged."""
> +        merged = []
> +        temp_index = self.__stack.repository.temp_index()
> +        temp_index_tree = None

There's no need to create a new temp index here. The transaction object already has one.

-- 
Karl Hasselström, kha@treskal.com
      www.treskal.com/kalle
Previous: Catalin MarinasNext: Catalin Marinas
Message 2 of 10 in “Add the --merged option to goto”
  1. Add the --merged option to gotoCatalin Marinas, Mar 20, 2009
  2. Karl HasselströmMar 23, 2009
  3. Catalin MarinasMar 23, 2009
  4. Karl HasselströmMar 24, 2009
  5. Catalin MarinasMar 24, 2009
  6. Karl HasselströmMar 25, 2009
  7. Catalin MarinasMar 25, 2009
  8. Karl HasselströmMar 26, 2009
  9. Catalin MarinasMar 30, 2009
  10. Karl HasselströmMar 31, 2009

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.