# [PATCH 0/2] Series short description

6 messages from 2006-08-14 to 2006-09-03. Participants: Yann Dirson, Catalin Marinas, Junio C Hamano.
Thread: https://gitlist.dev/t/5246

## Yann Dirson, 2006-08-14 16:53

Subject: [PATCH 0/2] Series short description
Message-ID: <20060814165307.20350.63286.stgit@gandelf.nowhere.earth>
URL: https://gitlist.dev/e/20060814165307.20350.63286.stgit%40gandelf.nowhere.earth

```
The following series allow to pick from all over the tree, even if your tree
is full of merge commits, and if you use grafts extensively.

The series is not really complete, it lacks a fix for a nasty bug that
crashes stgit when "pick" encounters a file-creation conflict.  But
nevertheless, I would not have been able to do my job today without them :)
-- 
Yann Dirson    <ydirson@altern.org> |
Debian-related: <dirson@debian.org> |   Support Debian GNU/Linux:
                                    |  Freedom, Power, Stability, Gratis
     http://ydirson.free.fr/        | Check <http://www.debian.org/>

```

## Yann Dirson, 2006-08-14 16:55

Subject: [PATCH 1/2] Add a --parent flag to "stgit pick".
Message-ID: <20060814165542.20350.34612.stgit@gandelf.nowhere.earth>
URL: https://gitlist.dev/e/20060814165542.20350.34612.stgit%40gandelf.nowhere.earth
In-Reply-To: <20060814165307.20350.63286.stgit@gandelf.nowhere.earth>

```

This is useful to pick changes from a non-stgit branch, that were
recorded as a merge commit, while giving control on the parent to
use as "bottom" for the patch (for some reason stgit selects the
first parent by default).

Incidentally, it can be used to pick changes between arbitrary
trees in the revision graph.  Since that can be useful as well,
I did not implement the is_parent check I originally meant to add.

Signed-off-by: Yann Dirson <ydirson@altern.org>
---

 stgit/commands/pick.py |   11 +++++++++--
 1 files changed, 9 insertions(+), 2 deletions(-)

diff --git a/stgit/commands/pick.py b/stgit/commands/pick.py
index 1aa83d0..2916b6e 100644
--- a/stgit/commands/pick.py
+++ b/stgit/commands/pick.py
@@ -37,6 +37,8 @@ options = [make_option('-n', '--name',
            make_option('-r', '--reverse',
                        help = 'reverse the commit object before importing',
                        action = 'store_true'),
+           make_option('-p', '--parent',
+                       help = 'use COMMITID as parent'),
            make_option('--fold',
                        help = 'fold the commit object into the current patch',
                        action = 'store_true'),
@@ -73,12 +75,17 @@ def func(parser, options, args):
             if not patch:
                 raise CmdException, 'Unknown patch name'
 
+    if options.parent:
+        parent = options.parent
+    else:
+        parent = commit.get_parent()
+
     if not options.reverse:
-        bottom = commit.get_parent()
+        bottom = parent
         top = commit_id
     else:
         bottom = commit_id
-        top = commit.get_parent()
+        top = parent
 
     if options.fold:
         print 'Folding commit %s...' % commit_id,

```

## Yann Dirson, 2006-08-14 16:55

Subject: [PATCH 2/2] Look for a commit's parents in the standard way.
Message-ID: <20060814165544.20350.41590.stgit@gandelf.nowhere.earth>
URL: https://gitlist.dev/e/20060814165544.20350.41590.stgit%40gandelf.nowhere.earth
In-Reply-To: <20060814165307.20350.63286.stgit@gandelf.nowhere.earth>

```

This has the direct effect of taking info/grafts into account, since
ignoring it only causes confusion.

My original implementation was pasted from the same fix applied to
cogito some time ago.  That one is hopefully more pythonic, but it
looks like split() is deprecated for some reason, and I don't know
what should be used instead.

Signed-off-by: Yann Dirson <ydirson@altern.org>
---

 stgit/git.py |   10 ++++++----
 1 files changed, 6 insertions(+), 4 deletions(-)

diff --git a/stgit/git.py b/stgit/git.py
index c8b7b8f..68b547c 100644
--- a/stgit/git.py
+++ b/stgit/git.py
@@ -19,6 +19,7 @@ Foundation, Inc., 59 Temple Place, Suite
 """
 
 import sys, os, popen2, re, gitmergeonefile
+from string import split
 
 from stgit import basedir
 from stgit.utils import *
@@ -47,12 +48,13 @@ class Commit:
             field = line.strip().split(' ', 1)
             if field[0] == 'tree':
                 self.__tree = field[1]
-            elif field[0] == 'parent':
-                self.__parents.append(field[1])
-            if field[0] == 'author':
+            #elif field[0] == 'parent':
+                #self.__parents.append(field[1])
+            elif field[0] == 'author':
                 self.__author = field[1]
-            if field[0] == 'committer':
+            elif field[0] == 'committer':
                 self.__committer = field[1]
+        self.__parents = split(_output_lines('git-rev-list --parents --max-count=1 %s' % id_hash)[0])[1:]
         self.__log = ''.join(lines[i+1:])
 
     def get_id_hash(self):

```

## Catalin Marinas, 2006-08-20 10:43

Subject: Re: [PATCH 2/2] Look for a commit's parents in the standard way.
Message-ID: <b0943d9e0608200343t517ec29dw2b6b49d9d69dbad5@mail.gmail.com>
URL: https://gitlist.dev/e/b0943d9e0608200343t517ec29dw2b6b49d9d69dbad5%40mail.gmail.com
In-Reply-To: <20060814165544.20350.41590.stgit@gandelf.nowhere.earth>

```
On 14/08/06, Yann Dirson <ydirson@altern.org> wrote:
> This has the direct effect of taking info/grafts into account, since
> ignoring it only causes confusion.

I don't know the difference but is there any between parsing the
commit file and using git-rev-list --parents?

> +        self.__parents = split(_output_lines('git-rev-list --parents --max-count=1 %s' % id_hash)[0])[1:]

Instead of using the split() method, you could call
_output_lines('git-rev-list --parents --max-count=1 %s' %
id_hash)[0].split()[1:]. Maybe that's why they might deprecate the
global split method.

Setting self.__parents by calling get-rev-list would have a
performance impact on the push operation. I think we could remove the
__parents variable and only call git-rev-parse in get_parents() or
get_parent().

-- 
Catalin

```

## Junio C Hamano, 2006-08-22 06:42

Subject: Re: [PATCH 2/2] Look for a commit's parents in the standard way.
Message-ID: <7vd5ats24g.fsf@assigned-by-dhcp.cox.net>
URL: https://gitlist.dev/e/7vd5ats24g.fsf%40assigned-by-dhcp.cox.net
In-Reply-To: <b0943d9e0608200343t517ec29dw2b6b49d9d69dbad5@mail.gmail.com>

```
"Catalin Marinas" <catalin.marinas@gmail.com> writes:

> On 14/08/06, Yann Dirson <ydirson@altern.org> wrote:
>> This has the direct effect of taking info/grafts into account, since
>> ignoring it only causes confusion.
>
> I don't know the difference but is there any between parsing the
> commit file and using git-rev-list --parents?

If you mean parsing "cat-file commit" output vs "rev-list
--parents" output, the former shows the true parents while the
latter shows a list of parents adjusted with information in the
grafts file.

If you are using pathspec then the latter further simplifies the
parent list, but you know that already and you are not using
that form here.

```

## Yann Dirson, 2006-09-03 19:36

Subject: Re: [PATCH 2/2] Look for a commit's parents in the standard way.
Message-ID: <20060903193650.GA4914@nan92-1-81-57-214-146.fbx.proxad.net>
URL: https://gitlist.dev/e/20060903193650.GA4914%40nan92-1-81-57-214-146.fbx.proxad.net
In-Reply-To: <b0943d9e0608200343t517ec29dw2b6b49d9d69dbad5@mail.gmail.com>

```
On Sun, Aug 20, 2006 at 11:43:22AM +0100, Catalin Marinas wrote:
> On 14/08/06, Yann Dirson <ydirson@altern.org> wrote:
> >This has the direct effect of taking info/grafts into account, since
> >ignoring it only causes confusion.
> 
> I don't know the difference but is there any between parsing the
> commit file and using git-rev-list --parents?

Yes, git-rev-list at least takes info/grafts into account.

> >+        self.__parents = split(_output_lines('git-rev-list --parents 
> >--max-count=1 %s' % id_hash)[0])[1:]
> 
> Instead of using the split() method, you could call
> _output_lines('git-rev-list --parents --max-count=1 %s' %
> id_hash)[0].split()[1:]. Maybe that's why they might deprecate the
> global split method.

Ah, OK.

Best regards,
-- 
Yann.

-- 
VGER BF report: U 0.500235

```
