git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Karl Hasselström" <kha@treskal.com>
To: Catalin Marinas <catalin.marinas@gmail.com>
Cc: git@vger.kernel.org
Subject: [StGit PATCH 07/14] Log conflicts separately for all commands
Date: Thu, 12 Jun 2008 07:34:50 +0200	[thread overview]
Message-ID: <20080612053450.23549.69382.stgit@yoghurt> (raw)
In-Reply-To: <20080612052913.23549.69687.stgit@yoghurt>

This takes care of the old-infrastructure commands as well. They'll
all be converted to the new infrastructure eventually, but until then
this patch is necessary to make all commands behave consistently.

Signed-off-by: Karl Hasselström <kha@treskal.com>

---

 stgit/lib/log.py   |   32 +++++++++++++++++++++++++++++++-
 stgit/lib/stack.py |    7 +++++++
 2 files changed, 38 insertions(+), 1 deletions(-)


diff --git a/stgit/lib/log.py b/stgit/lib/log.py
index 8646e08..920c261 100644
--- a/stgit/lib/log.py
+++ b/stgit/lib/log.py
@@ -174,12 +174,42 @@ def log_entry(stack, msg):
                                   + [ll.full_log for ll in last_log])))
     stack.repository.refs.set(ref, full_log, msg)
 
+class Fakestack(object):
+    """Imitates a real L{Stack<stgit.lib.stack.Stack>}, but with the
+    topmost patch popped."""
+    def __init__(self, stack):
+        appl = list(stack.patchorder.applied)
+        unappl = list(stack.patchorder.unapplied)
+        class patchorder(object):
+            applied = appl[:-1]
+            unapplied = [appl[-1]] + unappl
+            all = appl + unappl
+        self.patchorder = patchorder
+        class patches(object):
+            @staticmethod
+            def get(pn):
+                if pn == appl[-1]:
+                    class patch(object):
+                        commit = stack.patches.get(pn).old_commit
+                    return patch
+                else:
+                    return stack.patches.get(pn)
+        self.patches = patches
+        self.head = stack.head.data.parent
+        self.top = stack.top.data.parent
+        self.base = stack.base
+        self.name = stack.name
+        self.repository = stack.repository
 def compat_log_entry(msg):
     """Write a new log entry. (Convenience function intended for use by
     code not yet converted to the new infrastructure.)"""
     repo = default_repo()
     stack = repo.get_stack(repo.current_branch_name)
-    log_entry(stack, msg)
+    if repo.default_index.conflicts():
+        log_entry(Fakestack(stack), msg)
+        log_entry(stack, msg + ' (CONFLICT)')
+    else:
+        log_entry(stack, msg)
 
 class Log(object):
     """Class used to read the stack log. Each instance represents one log
diff --git a/stgit/lib/stack.py b/stgit/lib/stack.py
index 62a1ec2..2d686e6 100644
--- a/stgit/lib/stack.py
+++ b/stgit/lib/stack.py
@@ -25,6 +25,13 @@ class Patch(object):
     def commit(self):
         return self.__stack.repository.refs.get(self.__ref)
     @property
+    def old_commit(self):
+        """Return the previous commit for this patch."""
+        fn = os.path.join(self.__compat_dir, 'top.old')
+        if not os.path.isfile(fn):
+            return None
+        return self.__stack.repository.get_commit(utils.read_string(fn))
+    @property
     def __compat_dir(self):
         return os.path.join(self.__stack.directory, 'patches', self.__name)
     def __write_compat_files(self, new_commit, msg):

  parent reply	other threads:[~2008-06-12  5:36 UTC|newest]

Thread overview: 32+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-06-12  5:34 [StGit PATCH 00/14] Undo series Karl Hasselström
2008-06-12  5:34 ` [StGit PATCH 01/14] Fix typo Karl Hasselström
2008-06-12  5:34 ` [StGit PATCH 02/14] Library functions for tree and blob manipulation Karl Hasselström
2008-06-12  5:34 ` [StGit PATCH 03/14] Write to a stack log when stack is modified Karl Hasselström
2008-06-17 10:24   ` Catalin Marinas
2008-06-17 12:31     ` Karl Hasselström
2008-06-17 12:55       ` Karl Hasselström
2008-06-17 14:11       ` Catalin Marinas
2008-06-17 15:32         ` Karl Hasselström
2008-06-18 13:03           ` Catalin Marinas
2008-06-18 14:36             ` Karl Hasselström
2008-06-18 16:16               ` Catalin Marinas
2008-06-18 17:32                 ` Karl Hasselström
2008-06-19  9:24                   ` Catalin Marinas
2008-06-19 10:07                     ` Karl Hasselström
2008-06-20  9:14                       ` Catalin Marinas
2008-06-23 12:36                         ` Karl Hasselström
2008-07-12 10:09                           ` Catalin Marinas
2008-07-14  6:32                             ` Karl Hasselström
2008-07-01 20:13           ` Karl Hasselström
2008-07-03 22:05             ` Catalin Marinas
2008-06-12  5:34 ` [StGit PATCH 04/14] Add utility function for reordering patches Karl Hasselström
2008-06-12  5:34 ` [StGit PATCH 05/14] New command: stg reset Karl Hasselström
2008-06-12  5:34 ` [StGit PATCH 06/14] Log conflicts separately Karl Hasselström
2008-06-12  5:34 ` Karl Hasselström [this message]
2008-06-12  5:34 ` [StGit PATCH 08/14] Add a --hard flag to stg reset Karl Hasselström
2008-06-12  5:35 ` [StGit PATCH 09/14] Don't write a log entry if there were no changes Karl Hasselström
2008-06-12  5:35 ` [StGit PATCH 10/14] Move stack reset function to a shared location Karl Hasselström
2008-06-12  5:35 ` [StGit PATCH 11/14] New command: stg undo Karl Hasselström
2008-06-12  5:35 ` [StGit PATCH 12/14] New command: stg redo Karl Hasselström
2008-06-12  5:35 ` [StGit PATCH 13/14] Log and undo external modifications Karl Hasselström
2008-06-12  5:35 ` [StGit PATCH 14/14] Make "stg log" show stack log instead of patch log 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=20080612053450.23549.69382.stgit@yoghurt \
    --to=kha@treskal.com \
    --cc=catalin.marinas@gmail.com \
    --cc=git@vger.kernel.org \
    /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 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).