threads / patch / 5246

patch, 2 partsSeries short description

Subject: [PATCH 0/2] Series short description

## tl;dr

6 messages between Aug 14, 2006 and Sep 3, 2006. Diffs are folded; open one to read it.

replies: 5people: 4as markdown or json

Yann Dirson· Aug 14, 2006, 16:53 UTC · lore

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· Aug 14, 2006, 16:55 UTC · re: Yann Dirson · lore

[PATCH 1/2] Add a --parent flag to "stgit pick".

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(-)
Show changes to stgit/commands/pick.py +9 −2
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· Aug 14, 2006, 16:55 UTC · re: Yann Dirson · lore

[PATCH 2/2] Look for a commit's parents in the standard way.

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(-)
Show changes to stgit/git.py +6 −4
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· Aug 20, 2006, 10:43 UTC · re: Yann Dirson · lore

Re: [PATCH 2/2] Look for a commit's parents in the standard way.

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· Aug 22, 2006, 06:42 UTC · re: Catalin Marinas · lore

Re: [PATCH 2/2] Look for a commit's parents in the standard way.

"Catalin Marinas" <catalin.marinas@gmail.com> writes:
Show 6 quoted lines
> 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· Sep 3, 2006, 19:36 UTC · re: Catalin Marinas · lore

Re: [PATCH 2/2] Look for a commit's parents in the standard way.

On Sun, Aug 20, 2006 at 11:43:22AM +0100, Catalin Marinas wrote:
Show 6 quoted lines
> 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.
Show 7 quoted lines
> >+        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

← back to recent threads