git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[StGit PATCH 08/10] Log conflicts separately for all commands

From
Karl Hasselström <kha@treskal.com>
Date
Apr 20, 2008, 22:11 UTC
Message-ID
<20080420221107.5837.46522.stgit@yoghurt>
In-Reply-To
<20080420215625.5837.82896.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 the commands behave consistently.

Signed-off-by: Karl Hasselström <kha@treskal.com>
---
 stgit/lib/log.py   |   29 ++++++++++++++++++++++++++++-
 stgit/lib/stack.py |    7 +++++++
 2 files changed, 35 insertions(+), 1 deletions(-)
diff --git a/stgit/lib/log.py b/stgit/lib/log.py
index fac050f..9904941 100644
--- a/stgit/lib/log.py
+++ b/stgit/lib/log.py
@@ -58,10 +58,37 @@ 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 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.name = stack.name
+        self.repository = stack.repository
 def compat_log_entry(msg):
     repo = default_repo()
     stack = repo.get_stack(repo.current_branch)
-    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):
     """Read a log entry."""
diff --git a/stgit/lib/stack.py b/stgit/lib/stack.py
index af1c994..95b817f 100644
--- a/stgit/lib/stack.py
+++ b/stgit/lib/stack.py
@@ -17,6 +17,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):
Previous: Karl HasselströmNext: Karl Hasselström
Message 9 of 11 in “Updated "stg reset" series”
  1. 00/10 Updated "stg reset" seriesKarl Hasselström, Apr 20, 2008
  2. 01/10 Prevent most commands from running when there are conflictsKarl Hasselström, Apr 20, 2008
  3. 02/10 Add property with a list of all patch namesKarl Hasselström, Apr 20, 2008
  4. 03/10 Library functions for tree and blob manipulationKarl Hasselström, Apr 20, 2008
  5. 04/10 Write to a stack log when stack is modifiedKarl Hasselström, Apr 20, 2008
  6. 05/10 Add utility function for reordering patchesKarl Hasselström, Apr 20, 2008
  7. 06/10 New command: stg resetKarl Hasselström, Apr 20, 2008
  8. 07/10 Log conflicts separatelyKarl Hasselström, Apr 20, 2008
  9. 08/10 Log conflicts separately for all commandsKarl Hasselström, Apr 20, 2008
  10. 09/10 Add a --hard flag to stg resetKarl Hasselström, Apr 20, 2008
  11. 10/10 Don't write a log entry if there were no changesKarl Hasselström, Apr 20, 2008

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.