Subject: [PATCH] fix stg edit command

!MAILaRCHIVE_VOTE_RePLACE
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
To: Karl <kha@...>
Cc: Catalin Marinas <catalin.marinas@...>, <git@...>, David <davidk@...>
Date: Tuesday, February 12, 2008 - 6:05 pm

The comparison of two Commitdata objects returned False.
Signed-off-by: Peter Oberndorfer <kumbayo84@arcor.de>
---

On Sonntag 10 Februar 2008, Karl Hasselström wrote:

While testing my editor searching ordering patch i found that
this patch(Refactor --author/--committer options) seems to break
"stg edit" (without arguments) starting a interactive editor for me.
When i issue "stg edit" it silently does nothing.

It seems the following comparison does not return True


I can work around this by adding a comparison function to Commitdata
but maybe __eq__ or __ne__ should be used instead(prevent similar bugs caused
by == comparison)?
I would guess the initial cause for this is that the following line which unconditionally replaces cd.


So another way to fix this might be, to not overwrite cd unconditionally.

Greetings Peter

 stgit/commands/edit.py |    2 +-
 stgit/lib/git.py       |    8 ++++++++
 2 files changed, 9 insertions(+), 1 deletions(-)

diff --git a/stgit/commands/edit.py b/stgit/commands/edit.py
index 037425b..9439fb6 100644
--- a/stgit/commands/edit.py
+++ b/stgit/commands/edit.py
@@ -146,7 +146,7 @@ def func(parser, options, args):
         return utils.STGIT_SUCCESS
 
     # Let user edit the patch manually.
-    if cd == orig_cd or options.edit:
+    if cd.is_same(orig_cd) or options.edit:
         fn = '.stgit-edit.' + ['txt', 'patch'][bool(options.diff)]
         cd, failed_diff = update_patch_description(
             stack.repository, cd, utils.edit_string(
diff --git a/stgit/lib/git.py b/stgit/lib/git.py
index 6ee8a71..b62d14c 100644
--- a/stgit/lib/git.py
+++ b/stgit/lib/git.py
@@ -202,6 +202,14 @@ class Commitdata(Repr):
         return ('Commitdata<tree: %s, parents: %s, author: %s,'
                 ' committer: %s, message: "%s">'
                 ) % (tree, parents, self.author, self.committer, self.message)
+
+    def is_same(self, other):
+        return (self.__tree == other.__tree and
+                self.__parents == other.__parents and
+                self.__author == other.__author and
+                self.__committer == other.__committer and
+                self.__message == other.__message)
+
     @classmethod
     def parse(cls, repository, s):
         cd = cls()
-- 
1.5.4.rc3

-
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
StGit: kha/safe and kha/experimental updated, Karl , (Sun Feb 10, 4:36 pm)
Re: StGit: kha/safe and kha/experimental updated, Catalin Marinas, (Tue Feb 12, 1:54 pm)
[StGit PATCH 2/2] Emacs mode: delete patches, Karl , (Sun Feb 10, 4:54 pm)
Re: [StGit PATCH 2/2] Emacs mode: delete patches, David Kågedal, (Mon Feb 11, 5:42 am)
Re: [StGit PATCH 2/2] Emacs mode: delete patches, David Kågedal, (Mon Feb 11, 6:12 am)
Re: [StGit PATCH 5/5] Emacs mode: use "stg new --file", David Kågedal, (Mon Feb 11, 5:25 am)
Subject: [PATCH] fix stg edit command, Peter Oberndorfer, (Tue Feb 12, 6:05 pm)
Re: Subject: [PATCH] fix stg edit command, Karl , (Tue Feb 12, 6:47 pm)