All of lore.kernel.org
 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 automatic git-mergetool invocation to the new  infrastructure
Date: Wed, 11 Feb 2009 10:48:00 +0000	[thread overview]
Message-ID: <b0943d9e0902110248n7aa14743p19079e3d967f77a9@mail.gmail.com> (raw)
In-Reply-To: <20090211092028.GC26136@diana.vm.bytemark.co.uk>

2009/2/11 Karl Hasselström <kha@treskal.com>:
> On 2009-02-10 14:14:07 +0000, Catalin Marinas wrote:
>> I'm still not entirely sure where the check for stgit.autoimerge
>> should be done. In the classic infrastructure, it is done in the
>> merge function. With this patch, it is done in Transaction.push().
>> Should we push this even further to stgit.commands.push? My opinion
>> is not since by having it in Transaction we get the advantage not
>> listing the conflicts if the mergetool succeeds and we don't need to
>> abort the transaction.
>
> Yes, one advantage of having it here is that if the user resolves the
> conflict, we can just continue. I'm not sure I personally like that
> mode of operation -- you might have guessed by now that I like
> noninteractive mechanisms -- but I can see how it's useful to someone
> who does.

I find it useful when I prepare a kernel release and pick patches from
many branches, it saves some typing with having to run the mergetool
and restart the pick or push command. It's also useful for "sync".

> Another advantage of having it here is that it automatically just
> works for all commands, not just "stg push".

It works for commands that use Transaction.push_patch(). Other
commands that use IndexAndWorktree.merge() via some other function
would not work. Will there be such functions? I suspect a "sync"
implementation would need additional support in Transaction.

Any thoughts on calling mergetool from IndexAndWorktree.merge() (with
an additional parameter to explicitly enable this rather than just
reading the config option)?

> The disadvantage that I see is that we ask the user to put work into
> resolving conflicts before we've made sure that we won't roll back the
> whole transaction. If this is to become a dependable feature, we need
> a way to make sure we'll never throw away the user's work.

Maybe push_patch() can receive a parameter on whether to invoke
mergetool. The calling code should know the behaviour for aborting
transactions and only ask for interactivity if the command is expected
to leave conflicts in the index.

>> --- a/stgit/lib/git.py
>> +++ b/stgit/lib/git.py
>> @@ -842,6 +842,12 @@ class IndexAndWorktree(RunWithEnvCwd):
>>                  raise MergeConflictException(conflicts)
>>          except run.RunException, e:
>>              raise MergeException('Index/worktree dirty')
>> +    def mergetool(self, files = []):
>> +        """Invoke 'git mergetool' on the current IndexAndWorktree to resolve
>> +        any outstanding conflicts."""
>> +        err = os.system('git mergetool %s' % ' '.join(files))
>> +        if err:
>> +            raise MergeException('"git mergetool" failed, exit code: %d' % err)
>>      def changed_files(self, tree, pathlimits = []):
>>          """Return the set of files in the worktree that have changed with
>>          respect to C{tree}. The listing is optionally restricted to
>
> This is the right place for this method. But what happens if "files"
> isn't specified -- do we operate on all files then? The method
> documentation should probably say this.

Yes, it operates on all, I'll add a comment.

> (Small style tip: In Python, you're free to mutate the default values
> of your arguments, and those changes will be visible the next time you
> call the funtction. You don't change "files" in this function, but
> it's probably still a good idea to make the default value an immutable
> type, such as tuple.)

I've bean hit by this problem in the past but haven't learned :-).

-- 
Catalin

  reply	other threads:[~2009-02-11 10:49 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-02-10 14:14 [StGit PATCH] Add automatic git-mergetool invocation to the new infrastructure Catalin Marinas
2009-02-11  9:20 ` Karl Hasselström
2009-02-11 10:48   ` Catalin Marinas [this message]
2009-02-11 13:11     ` 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=b0943d9e0902110248n7aa14743p19079e3d967f77a9@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.