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

Re: [StGit PATCH] Convert "sink" to the new infrastructure

From
CMCatalin Marinas <catalin.marinas@gmail.com>
Date
Sep 17, 2008, 16:09 UTC
Message-ID
<b0943d9e0809170909j4fce34acr8f0b844d0cb5281d@mail.gmail.com>
In-Reply-To
<20080916193647.GA12513@diana.vm.bytemark.co.uk>
2008/9/16 Karl Hasselström <kha@treskal.com>:
Show 17 quoted lines
> On 2008-09-16 15:59:31 +0100, Catalin Marinas wrote:
>
>> 2008/9/16 Karl Hasselström <kha@treskal.com>:
>>
>> > iw is the index+worktree object. The idea is that you provide one
>> > if your branch is checked out, and not if not. Operations that
>> > have no need of index+worktree, like pop, and push in case
>> > automatic merging succeeds, will just work anyway, while
>> > operations that need index+worktree, such as a conflicting push,
>> > will cause the whole transaction to abort.
>>
>> Ah, that's the difference. I thought that even if iw isn't passed,
>> it uses the default one.
>
> It wouldn't be clean of it to do that -- it would be accessing
> non-local state it had no business knowing about. I try hard to avoid
> that kind of thing.

I'm still confused by this and I don't think your new flag would help. The meaning of stop_before_conflict is that it won't push the conflicting patch but actually leave the stack with several patches pushed or popped.

What I want for sink (and float afterwards) is by default to cancel the whole transaction if there is a conflict and revert the stack to it's original state prior to the "stg sink" command. What I have in my code:

    iw = stack.repository.default_iw
    trans = transaction.StackTransaction(stack, 'sink')
    try:
        trans.reorder_patches(applied, unapplied, hidden, iw)
    except transaction.TransactionHalted:
        if not options.conflict:
            ??? here it needs to check out the previous iw
            raise
    return trans.run(iw)

It runs as expected if --conflict is given but in the default case, if there is a conflict, it keeps the original patchorder (as expected) but the worktree isn't clean. What do I replace ??? with to clean the work tree?

BTW, much shorter with reorder_patches.
-- 
Catalin
Previous: Catalin MarinasNext: Karl Hasselström
Message 15 of 18 in “Convert "sink" to the new infrastructure”
  1. Convert "sink" to the new infrastructureCatalin Marinas, Sep 12, 2008
  2. Karl HasselströmSep 14, 2008
  3. Catalin MarinasSep 14, 2008
  4. Karl HasselströmSep 15, 2008
  5. Catalin MarinasSep 15, 2008
  6. Karl HasselströmSep 16, 2008
  7. Catalin MarinasSep 16, 2008
  8. Karl HasselströmSep 16, 2008
  9. Catalin MarinasSep 17, 2008
  10. Karl HasselströmSep 17, 2008
  11. Karl HasselströmSep 17, 2008
  12. Catalin MarinasSep 17, 2008
  13. Karl HasselströmSep 18, 2008
  14. Catalin MarinasSep 18, 2008
  15. Catalin MarinasSep 17, 2008
  16. Karl HasselströmSep 18, 2008
  17. Catalin MarinasSep 18, 2008
  18. Karl HasselströmSep 18, 2008

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.