git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/2] Series short description
@ 2006-08-14 16:53 Yann Dirson
  2006-08-14 16:55 ` [PATCH 1/2] Add a --parent flag to "stgit pick" Yann Dirson
  2006-08-14 16:55 ` [PATCH 2/2] Look for a commit's parents in the standard way Yann Dirson
  0 siblings, 2 replies; 6+ messages in thread
From: Yann Dirson @ 2006-08-14 16:53 UTC (permalink / raw)
  To: Catalin Marinas; +Cc: git

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/>

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH 1/2] Add a --parent flag to "stgit pick".
  2006-08-14 16:53 [PATCH 0/2] Series short description Yann Dirson
@ 2006-08-14 16:55 ` Yann Dirson
  2006-08-14 16:55 ` [PATCH 2/2] Look for a commit's parents in the standard way Yann Dirson
  1 sibling, 0 replies; 6+ messages in thread
From: Yann Dirson @ 2006-08-14 16:55 UTC (permalink / raw)
  To: Catalin Marinas; +Cc: git


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,

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH 2/2] Look for a commit's parents in the standard way.
  2006-08-14 16:53 [PATCH 0/2] Series short description Yann Dirson
  2006-08-14 16:55 ` [PATCH 1/2] Add a --parent flag to "stgit pick" Yann Dirson
@ 2006-08-14 16:55 ` Yann Dirson
  2006-08-20 10:43   ` Catalin Marinas
  1 sibling, 1 reply; 6+ messages in thread
From: Yann Dirson @ 2006-08-14 16:55 UTC (permalink / raw)
  To: Catalin Marinas; +Cc: git


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):

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH 2/2] Look for a commit's parents in the standard way.
  2006-08-14 16:55 ` [PATCH 2/2] Look for a commit's parents in the standard way Yann Dirson
@ 2006-08-20 10:43   ` Catalin Marinas
  2006-08-22  6:42     ` Junio C Hamano
  2006-09-03 19:36     ` Yann Dirson
  0 siblings, 2 replies; 6+ messages in thread
From: Catalin Marinas @ 2006-08-20 10:43 UTC (permalink / raw)
  To: Yann Dirson; +Cc: git

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

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH 2/2] Look for a commit's parents in the standard way.
  2006-08-20 10:43   ` Catalin Marinas
@ 2006-08-22  6:42     ` Junio C Hamano
  2006-09-03 19:36     ` Yann Dirson
  1 sibling, 0 replies; 6+ messages in thread
From: Junio C Hamano @ 2006-08-22  6:42 UTC (permalink / raw)
  To: git

"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.

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH 2/2] Look for a commit's parents in the standard way.
  2006-08-20 10:43   ` Catalin Marinas
  2006-08-22  6:42     ` Junio C Hamano
@ 2006-09-03 19:36     ` Yann Dirson
  1 sibling, 0 replies; 6+ messages in thread
From: Yann Dirson @ 2006-09-03 19:36 UTC (permalink / raw)
  To: Catalin Marinas; +Cc: git

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

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2006-09-03 19:37 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-08-14 16:53 [PATCH 0/2] Series short description Yann Dirson
2006-08-14 16:55 ` [PATCH 1/2] Add a --parent flag to "stgit pick" Yann Dirson
2006-08-14 16:55 ` [PATCH 2/2] Look for a commit's parents in the standard way Yann Dirson
2006-08-20 10:43   ` Catalin Marinas
2006-08-22  6:42     ` Junio C Hamano
2006-09-03 19:36     ` Yann Dirson

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).