{"thread":{"id":"19107","subject":"[StGit PATCH 4/9] Convert 'clone' to the use stgit.lib","startedAt":"2009-04-28T15:09:35Z","lastAt":"2009-05-30T00:36:27Z","messageCount":27,"participants":["Catalin Marinas","Karl Hasselström","Samuel Tardieu","Shinya Kuribayashi"],"isPatch":true,"patchVersion":1,"patchTotal":9},"messages":[{"id":"112531","messageId":"20090428150742.27261.19620.stgit@pc1117.cambridge.arm.com","threadId":"19107","inReplyTo":null,"subject":"[StGit PATCH 0/9] Various StGit updates","fromName":"Catalin Marinas","fromEmail":"catalin.marinas@arm.com","sentAt":"2009-04-28T15:09:35Z","receivedAt":"2009-04-28T15:09:35Z","isPatch":true,"sender":{"key":"catalin.marinas@arm.com","avatar":null},"body":"These are the patches in my \"proposed\" branch to be moved into master\nonce reviewed.\n\nThanks.\n\n\nCatalin Marinas (9):\n      Use the default git colouring scheme rather than specific scripts\n      Add the log --clear option\n      Reinstate the --annotate option for refresh\n      Convert 'unhide' to the lib infrastructure\n      Convert 'hide' to the lib infrastructure\n      Convert 'clone' to the use stgit.lib\n      Do not sleep after the last patch sent by e-mail\n      Show some progress information when checking for upstream merges.\n      Show \"Pushing <patch>...done\" when pushing a patch\n\n\n contrib/diffcol.sh        |   51 ---------------------------------------------\n examples/gitconfig        |    4 ++--\n setup.py                  |    3 +--\n stgit/commands/clone.py   |   30 +++++++++++---------------\n stgit/commands/common.py  |    8 +++++++\n stgit/commands/diff.py    |    2 ++\n stgit/commands/hide.py    |   44 +++++++++++++++++++++------------------\n stgit/commands/log.py     |    9 +++++++-\n stgit/commands/mail.py    |   15 ++++++++-----\n stgit/commands/refresh.py |   13 +++++++++--\n stgit/commands/show.py    |    1 +\n stgit/commands/unhide.py  |   39 +++++++++++++++++++---------------\n stgit/config.py           |   10 ++++-----\n stgit/lib/git.py          |    4 ++++\n stgit/lib/transaction.py  |   15 ++++++++-----\n 15 files changed, 117 insertions(+), 131 deletions(-)\n delete mode 100755 contrib/diffcol.sh\n\n-- \nCatalin\n"},{"id":"112530","messageId":"20090428150940.27261.65680.stgit@pc1117.cambridge.arm.com","threadId":"19107","inReplyTo":"20090428150742.27261.19620.stgit@pc1117.cambridge.arm.com","subject":"[StGit PATCH 1/9] Show \"Pushing <patch>...done\" when pushing a patch","fromName":"Catalin Marinas","fromEmail":"catalin.marinas@arm.com","sentAt":"2009-04-28T15:09:40Z","receivedAt":"2009-04-28T15:09:40Z","isPatch":true,"sender":{"key":"catalin.marinas@arm.com","avatar":null},"body":"My main reason is for the automatic invocation of the interactive merge\nwhen I don't know what patch I have to deal with. The other reasons is\nfor people working over slow filesystems (NFS) where a three-way merging\nmay take a significant amount of time.\n\nSigned-off-by: Catalin Marinas <catalin.marinas@gmail.com>\n---\n stgit/lib/transaction.py |   13 +++++++------\n 1 files changed, 7 insertions(+), 6 deletions(-)\n\ndiff --git a/stgit/lib/transaction.py b/stgit/lib/transaction.py\nindex 4148ff3..582ee72 100644\n--- a/stgit/lib/transaction.py\n+++ b/stgit/lib/transaction.py\n@@ -302,6 +302,7 @@ class StackTransaction(object):\n         \"\"\"Attempt to push the named patch. If this results in conflicts,\n         halts the transaction. If index+worktree are given, spill any\n         conflicts to them.\"\"\"\n+        out.start('Pushing patch \"%s\"' % pn)\n         orig_cd = self.patches[pn].data\n         cd = orig_cd.set_committer(None)\n         oldparent = cd.parent\n@@ -330,12 +331,12 @@ class StackTransaction(object):\n                 iw.merge(base, ours, theirs, interactive = interactive)\n                 tree = iw.index.write_tree()\n                 self.__current_tree = tree\n-                s = ' (modified)'\n+                s = 'modified'\n             except git.MergeConflictException, e:\n                 tree = ours\n                 merge_conflict = True\n                 self.__conflicts = e.conflicts\n-                s = ' (conflict)'\n+                s = 'conflict'\n             except git.MergeException, e:\n                 self.__halt(str(e))\n         cd = cd.set_tree(tree)\n@@ -345,12 +346,12 @@ class StackTransaction(object):\n             self.head = comm\n         else:\n             comm = None\n-            s = ' (unmodified)'\n+            s = 'unmodified'\n         if already_merged:\n-            s = ' (merged)'\n+            s = 'merged'\n         elif not merge_conflict and cd.is_nochange():\n-            s = ' (empty)'\n-        out.info('Pushed %s%s' % (pn, s))\n+            s = 'empty'\n+        out.done(s)\n         def update():\n             if comm:\n                 self.patches[pn] = comm\n"},{"id":"112532","messageId":"20090428150946.27261.60198.stgit@pc1117.cambridge.arm.com","threadId":"19107","inReplyTo":"20090428150742.27261.19620.stgit@pc1117.cambridge.arm.com","subject":"[StGit PATCH 2/9] Show some progress information when checking for upstream merges.","fromName":"Catalin Marinas","fromEmail":"catalin.marinas@arm.com","sentAt":"2009-04-28T15:09:46Z","receivedAt":"2009-04-28T15:09:46Z","isPatch":true,"sender":{"key":"catalin.marinas@arm.com","avatar":null},"body":"Signed-off-by: Catalin Marinas <catalin.marinas@gmail.com>\n---\n stgit/lib/transaction.py |    2 ++\n 1 files changed, 2 insertions(+), 0 deletions(-)\n\ndiff --git a/stgit/lib/transaction.py b/stgit/lib/transaction.py\nindex 582ee72..13323dd 100644\n--- a/stgit/lib/transaction.py\n+++ b/stgit/lib/transaction.py\n@@ -390,6 +390,7 @@ class StackTransaction(object):\n \n     def check_merged(self, patches):\n         \"\"\"Return a subset of patches already merged.\"\"\"\n+        out.start('Checking for patches merged upstream')\n         merged = []\n         if self.temp_index_tree != self.stack.head.data.tree:\n             self.temp_index.read_tree(self.stack.head.data.tree)\n@@ -408,4 +409,5 @@ class StackTransaction(object):\n                 self.temp_index_tree = None\n             except git.MergeException:\n                 pass\n+        out.done('%d found' % len(merged))\n         return merged\n"},{"id":"112534","messageId":"20090428150952.27261.5637.stgit@pc1117.cambridge.arm.com","threadId":"19107","inReplyTo":"20090428150742.27261.19620.stgit@pc1117.cambridge.arm.com","subject":"[StGit PATCH 3/9] Do not sleep after the last patch sent by e-mail","fromName":"Catalin Marinas","fromEmail":"catalin.marinas@arm.com","sentAt":"2009-04-28T15:09:52Z","receivedAt":"2009-04-28T15:09:52Z","isPatch":true,"sender":{"key":"catalin.marinas@arm.com","avatar":null},"body":"Signed-off-by: Catalin Marinas <catalin.marinas@gmail.com>\n---\n stgit/commands/mail.py |   15 +++++++++------\n 1 files changed, 9 insertions(+), 6 deletions(-)\n\ndiff --git a/stgit/commands/mail.py b/stgit/commands/mail.py\nindex 46e4b55..69b19fa 100644\n--- a/stgit/commands/mail.py\n+++ b/stgit/commands/mail.py\n@@ -219,7 +219,7 @@ def __send_message_smtp(smtpserver, from_addr, to_addr_list, msg,\n     s.quit()\n \n def __send_message(smtpserver, from_addr, to_addr_list, msg,\n-                   sleep, smtpuser, smtppassword, use_tls):\n+                   smtpuser, smtppassword, use_tls):\n     \"\"\"Message sending dispatcher.\n     \"\"\"\n     if smtpserver.startswith('/'):\n@@ -229,8 +229,6 @@ def __send_message(smtpserver, from_addr, to_addr_list, msg,\n         # Use the SMTP server (we have host and port information)\n         __send_message_smtp(smtpserver, from_addr, to_addr_list, msg,\n                             smtpuser, smtppassword, use_tls)\n-    # give recipients a chance of receiving patches in the correct order\n-    time.sleep(sleep)\n \n def __build_address_headers(msg, options, extra_cc = []):\n     \"\"\"Build the address headers and check existing headers in the\n@@ -619,7 +617,8 @@ def func(parser, options, args):\n         else:\n             out.start('Sending the cover message')\n             __send_message(smtpserver, from_addr, to_addr_list, msg_string,\n-                           sleep, smtpuser, smtppassword, smtpusetls)\n+                           smtpuser, smtppassword, smtpusetls)\n+            time.sleep(sleep)\n             out.done()\n \n     # send the patches\n@@ -633,7 +632,7 @@ def func(parser, options, args):\n         if not tmpl:\n             raise CmdException, 'No e-mail template file found'\n \n-    for (p, patch_nr) in zip(patches, range(1, len(patches) + 1)):\n+    for (p, patch_nr) in zip(patches, range(1, total_nr + 1)):\n         msg_id = email.Utils.make_msgid('stgit')\n         msg = __build_message(tmpl, p, patch_nr, total_nr, msg_id, ref_id,\n                               options)\n@@ -650,5 +649,9 @@ def func(parser, options, args):\n         else:\n             out.start('Sending patch \"%s\"' % p)\n             __send_message(smtpserver, from_addr, to_addr_list, msg_string,\n-                           sleep, smtpuser, smtppassword, smtpusetls)\n+                           smtpuser, smtppassword, smtpusetls)\n+            # give recipients a chance of receiving related patches in the\n+            # correct order.\n+            if patch_nr < total_nr:\n+                time.sleep(sleep)\n             out.done()\n"},{"id":"112525","messageId":"20090428150957.27261.83658.stgit@pc1117.cambridge.arm.com","threadId":"19107","inReplyTo":"20090428150742.27261.19620.stgit@pc1117.cambridge.arm.com","subject":"[StGit PATCH 4/9] Convert 'clone' to the use stgit.lib","fromName":"Catalin Marinas","fromEmail":"catalin.marinas@arm.com","sentAt":"2009-04-28T15:09:57Z","receivedAt":"2009-04-28T15:09:57Z","isPatch":true,"sender":{"key":"catalin.marinas@arm.com","avatar":null},"body":"The patch also adds the stgit.lib.git.clone() function.\n\nSigned-off-by: Catalin Marinas <catalin.marinas@gmail.com>\n---\n stgit/commands/clone.py |   30 +++++++++++++-----------------\n stgit/lib/git.py        |    4 ++++\n 2 files changed, 17 insertions(+), 17 deletions(-)\n\ndiff --git a/stgit/commands/clone.py b/stgit/commands/clone.py\nindex 7fe9c35..369c8a9 100644\n--- a/stgit/commands/clone.py\n+++ b/stgit/commands/clone.py\n@@ -1,5 +1,5 @@\n __copyright__ = \"\"\"\n-Copyright (C) 2005, Catalin Marinas <catalin.marinas@gmail.com>\n+Copyright (C) 2009, Catalin Marinas <catalin.marinas@gmail.com>\n \n This program is free software; you can redistribute it and/or modify\n it under the terms of the GNU General Public License version 2 as\n@@ -15,10 +15,11 @@ along with this program; if not, write to the Free Software\n Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA\n \"\"\"\n \n-import sys, os\n-from stgit.commands.common import *\n-from stgit.utils import *\n-from stgit import argparse, stack, git\n+import os\n+from stgit.commands import common\n+from stgit.lib import git, stack\n+from stgit import argparse\n+from stgit.out import out\n \n help = 'Make a local clone of a remote repository'\n kind = 'repo'\n@@ -38,7 +39,7 @@ not already exist.\"\"\"\n args = [argparse.repo, argparse.dir]\n options = []\n \n-directory = DirectoryAnywhere(needs_current_series = False, log = False)\n+directory = common.DirectoryAnywhere(needs_current_series = False, log = False)\n \n def func(parser, options, args):\n     \"\"\"Clone the <repository> into the local <dir> and initialises the\n@@ -51,17 +52,12 @@ def func(parser, options, args):\n     local_dir = args[1]\n \n     if os.path.exists(local_dir):\n-        raise CmdException, '\"%s\" exists. Remove it first' % local_dir\n-\n-    print 'Cloning \"%s\" into \"%s\"...' % (repository, local_dir)\n+        raise common.CmdException, '\"%s\" exists. Remove it first' % local_dir\n \n+    out.start('Cloning \"%s\" into \"%s\"' % (repository, local_dir))\n     git.clone(repository, local_dir)\n     os.chdir(local_dir)\n-    git.checkout(tree_id = 'HEAD')\n-\n-    # be sure to forget any cached value for .git, since we're going\n-    # to work on a brand new repository\n-    basedir.clear_cache()\n-    stack.Series().init()\n-\n-    print 'done'\n+    directory = common.DirectoryHasRepositoryLib()\n+    directory.setup()\n+    stack.Stack.initialise(directory.repository)\n+    out.done()\ndiff --git a/stgit/lib/git.py b/stgit/lib/git.py\nindex 9c530c7..6f2c977 100644\n--- a/stgit/lib/git.py\n+++ b/stgit/lib/git.py\n@@ -933,3 +933,7 @@ def diffstat(diff):\n     \"\"\"Return the diffstat of the supplied diff.\"\"\"\n     return run.Run('git', 'apply', '--stat', '--summary'\n                    ).raw_input(diff).raw_output()\n+\n+def clone(remote, local):\n+    \"\"\"Clone a remote repository using 'git clone'.\"\"\"\n+    run.Run('git', 'clone', remote, local).run()\n"},{"id":"112529","messageId":"20090428151003.27261.72531.stgit@pc1117.cambridge.arm.com","threadId":"19107","inReplyTo":"20090428150742.27261.19620.stgit@pc1117.cambridge.arm.com","subject":"[StGit PATCH 5/9] Convert 'hide' to the lib infrastructure","fromName":"Catalin Marinas","fromEmail":"catalin.marinas@arm.com","sentAt":"2009-04-28T15:10:03Z","receivedAt":"2009-04-28T15:10:03Z","isPatch":true,"sender":{"key":"catalin.marinas@arm.com","avatar":null},"body":"Signed-off-by: Catalin Marinas <catalin.marinas@gmail.com>\n---\n stgit/commands/hide.py |   44 ++++++++++++++++++++++++--------------------\n 1 files changed, 24 insertions(+), 20 deletions(-)\n\ndiff --git a/stgit/commands/hide.py b/stgit/commands/hide.py\nindex 014febb..0b93a59 100644\n--- a/stgit/commands/hide.py\n+++ b/stgit/commands/hide.py\n@@ -1,5 +1,5 @@\n __copyright__ = \"\"\"\n-Copyright (C) 2007, Catalin Marinas <catalin.marinas@gmail.com>\n+Copyright (C) 2009, Catalin Marinas <catalin.marinas@gmail.com>\n \n This program is free software; you can redistribute it and/or modify\n it under the terms of the GNU General Public License version 2 as\n@@ -15,12 +15,10 @@ along with this program; if not, write to the Free Software\n Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA\n \"\"\"\n \n-import sys, os\n+from stgit.commands import common\n+from stgit.lib import transaction\n+from stgit import argparse\n from stgit.argparse import opt\n-from stgit.commands.common import *\n-from stgit.utils import *\n-from stgit.out import *\n-from stgit import argparse, stack, git\n \n help = 'Hide a patch in the series'\n kind = 'stack'\n@@ -29,25 +27,31 @@ description = \"\"\"\n Hide a range of unapplied patches so that they are no longer shown in\n the plain 'series' command output.\"\"\"\n \n-args = [argparse.patch_range(argparse.applied_patches,\n-                             argparse.unapplied_patches)]\n+args = [argparse.patch_range(argparse.unapplied_patches)]\n options = [\n     opt('-b', '--branch', args = [argparse.stg_branches],\n         short = 'Use BRANCH instead of the default branch')]\n \n-directory = DirectoryHasRepository(log = True)\n+directory = common.DirectoryHasRepositoryLib()\n \n def func(parser, options, args):\n-    \"\"\"Hide a range of patch in the series\n-    \"\"\"\n-    if args:\n-        # parsing all the patches for a more meaningful error reporting\n-        all_patches = crt_series.get_applied() + crt_series.get_unapplied() \\\n-                      + crt_series.get_hidden()\n-        patches = parse_patches(args, all_patches)\n-    else:\n+    \"\"\"Hide a range of patch in the series.\"\"\"\n+    stack = directory.repository.current_stack\n+    trans = transaction.StackTransaction(stack, 'hide')\n+\n+    if not args:\n         parser.error('No patches specified')\n \n-    for patch in patches:\n-        crt_series.hide_patch(patch)\n-        out.info('Patch \"%s\" hidden' % patch)\n+    patches = common.parse_patches(args, trans.all_patches)\n+    for p in patches:\n+        if p in trans.applied:\n+            raise common.CmdException('Cannot hide applied patch \"%s\"' % p)\n+        elif p in trans.hidden:\n+            raise common.CmdException('Patch \"%s\" already hidden' % p)\n+\n+    applied = list(trans.applied)\n+    unapplied = [p for p in trans.unapplied if not p in set(patches)]\n+    hidden = patches + trans.hidden\n+\n+    trans.reorder_patches(applied, unapplied, hidden)\n+    return trans.run()\n"},{"id":"112533","messageId":"20090428151008.27261.10237.stgit@pc1117.cambridge.arm.com","threadId":"19107","inReplyTo":"20090428150742.27261.19620.stgit@pc1117.cambridge.arm.com","subject":"[StGit PATCH 6/9] Convert 'unhide' to the lib infrastructure","fromName":"Catalin Marinas","fromEmail":"catalin.marinas@arm.com","sentAt":"2009-04-28T15:10:09Z","receivedAt":"2009-04-28T15:10:09Z","isPatch":true,"sender":{"key":"catalin.marinas@arm.com","avatar":null},"body":"Signed-off-by: Catalin Marinas <catalin.marinas@gmail.com>\n---\n stgit/commands/unhide.py |   39 +++++++++++++++++++++------------------\n 1 files changed, 21 insertions(+), 18 deletions(-)\n\ndiff --git a/stgit/commands/unhide.py b/stgit/commands/unhide.py\nindex 0c0832a..656ddea 100644\n--- a/stgit/commands/unhide.py\n+++ b/stgit/commands/unhide.py\n@@ -1,5 +1,5 @@\n __copyright__ = \"\"\"\n-Copyright (C) 2007, Catalin Marinas <catalin.marinas@gmail.com>\n+Copyright (C) 2009, Catalin Marinas <catalin.marinas@gmail.com>\n \n This program is free software; you can redistribute it and/or modify\n it under the terms of the GNU General Public License version 2 as\n@@ -15,12 +15,10 @@ along with this program; if not, write to the Free Software\n Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA\n \"\"\"\n \n-import sys, os\n+from stgit.commands import common\n+from stgit.lib import transaction\n+from stgit import argparse\n from stgit.argparse import opt\n-from stgit.commands.common import *\n-from stgit.utils import *\n-from stgit.out import *\n-from stgit import argparse, stack, git\n \n help = 'Unhide a hidden patch'\n kind = 'stack'\n@@ -34,19 +32,24 @@ options = [\n     opt('-b', '--branch', args = [argparse.stg_branches],\n         short = 'Use BRANCH instead of the default branch')]\n \n-directory = DirectoryHasRepository(log = True)\n+directory = common.DirectoryHasRepositoryLib()\n \n def func(parser, options, args):\n-    \"\"\"Unhide a range of patches in the series\n-    \"\"\"\n-    if args:\n-        # parsing all the patches for a more meaningful error reporting\n-        all_patches = crt_series.get_applied() + crt_series.get_unapplied() \\\n-                      + crt_series.get_hidden()\n-        patches = parse_patches(args, all_patches)\n-    else:\n+    \"\"\"Unhide a range of patch in the series.\"\"\"\n+    stack = directory.repository.current_stack\n+    trans = transaction.StackTransaction(stack, 'hide')\n+\n+    if not args:\n         parser.error('No patches specified')\n \n-    for patch in patches:\n-        crt_series.unhide_patch(patch)\n-        out.info('Patch \"%s\" unhidden' % patch)\n+    patches = common.parse_patches(args, trans.all_patches)\n+    for p in patches:\n+        if not p in trans.hidden:\n+            raise common.CmdException('Patch \"%s\" not hidden' % p)\n+\n+    applied = list(trans.applied)\n+    unapplied = trans.unapplied + patches\n+    hidden = [p for p in trans.hidden if not p in set(patches)]\n+\n+    trans.reorder_patches(applied, unapplied, hidden)\n+    return trans.run()\n"},{"id":"112526","messageId":"20090428151014.27261.18502.stgit@pc1117.cambridge.arm.com","threadId":"19107","inReplyTo":"20090428150742.27261.19620.stgit@pc1117.cambridge.arm.com","subject":"[StGit PATCH 7/9] Reinstate the --annotate option for refresh","fromName":"Catalin Marinas","fromEmail":"catalin.marinas@arm.com","sentAt":"2009-04-28T15:10:14Z","receivedAt":"2009-04-28T15:10:14Z","isPatch":true,"sender":{"key":"catalin.marinas@arm.com","avatar":null},"body":"It is sometimes useful to add some notes to the log entry when a patch\nwas refreshed. This option was dropped when the command was updated to\nthe new infrastructure as there was no logging support at that time.\n\nThe note will be visible with 'stg log {-g,-f}'\n\nSigned-off-by: Catalin Marinas <catalin.marinas@gmail.com>\n---\n stgit/commands/refresh.py |   13 ++++++++++---\n 1 files changed, 10 insertions(+), 3 deletions(-)\n\ndiff --git a/stgit/commands/refresh.py b/stgit/commands/refresh.py\nindex 5a5f979..c5a0aeb 100644\n--- a/stgit/commands/refresh.py\n+++ b/stgit/commands/refresh.py\n@@ -61,6 +61,8 @@ options = [\n         short = 'Refresh (applied) PATCH instead of the top patch'),\n     opt('-e', '--edit', action = 'store_true',\n         short = 'Invoke an editor for the patch description'),\n+    opt('-a', '--annotate', metavar = 'NOTE',\n+        short = 'Annotate the patch log entry')\n     ] + (argparse.message_options(save_template = False) +\n          argparse.sign_options() + argparse.author_options())\n \n@@ -200,9 +202,13 @@ def absorb_unapplied(trans, iw, patch_name, temp_name, edit_fun):\n         # leave the temp patch for the user.\n         return False\n \n-def absorb(stack, patch_name, temp_name, edit_fun):\n+def absorb(stack, patch_name, temp_name, edit_fun, annotate = None):\n     \"\"\"Absorb the temp patch into the target patch.\"\"\"\n-    trans = transaction.StackTransaction(stack, 'refresh')\n+    if annotate:\n+        log_msg = 'refresh\\n\\n' + annotate\n+    else:\n+        log_msg = 'refresh'\n+    trans = transaction.StackTransaction(stack, log_msg)\n     iw = stack.repository.default_iw\n     f = { True: absorb_applied, False: absorb_unapplied\n           }[patch_name in trans.applied]\n@@ -252,4 +258,5 @@ def func(parser, options, args):\n                 diff_flags = [], replacement_diff = None)\n             assert not failed_diff\n         return cd\n-    return absorb(stack, patch_name, temp_name, edit_fun)\n+    return absorb(stack, patch_name, temp_name, edit_fun,\n+                  annotate = options.annotate)\n"},{"id":"112528","messageId":"20090428151020.27261.27456.stgit@pc1117.cambridge.arm.com","threadId":"19107","inReplyTo":"20090428150742.27261.19620.stgit@pc1117.cambridge.arm.com","subject":"[StGit PATCH 8/9] Add the log --clear option","fromName":"Catalin Marinas","fromEmail":"catalin.marinas@arm.com","sentAt":"2009-04-28T15:10:20Z","receivedAt":"2009-04-28T15:10:20Z","isPatch":true,"sender":{"key":"catalin.marinas@arm.com","avatar":null},"body":"This option allows the clearing of the log history which sometimes may\nget too large.\n\nSigned-off-by: Catalin Marinas <catalin.marinas@gmail.com>\n---\n stgit/commands/log.py |    9 ++++++++-\n 1 files changed, 8 insertions(+), 1 deletions(-)\n\ndiff --git a/stgit/commands/log.py b/stgit/commands/log.py\nindex 3370e6c..92aaf0b 100644\n--- a/stgit/commands/log.py\n+++ b/stgit/commands/log.py\n@@ -50,7 +50,9 @@ options = [\n     opt('-f', '--full', action = 'store_true',\n         short = 'Show the full commit ids'),\n     opt('-g', '--graphical', action = 'store_true',\n-        short = 'Run gitk instead of printing')]\n+        short = 'Run gitk instead of printing'),\n+    opt('--clear', action = 'store_true',\n+        short = 'Clear the log history')]\n \n directory = common.DirectoryHasRepositoryLib()\n \n@@ -76,6 +78,11 @@ def func(parser, options, args):\n     except KeyError:\n         out.info('Log is empty')\n         return\n+\n+    if options.clear:\n+        log.delete_log(stack.repository, stack.name)\n+        return\n+\n     stacklog = log.get_log_entry(stack.repository, logref, logcommit)\n     pathlim = [os.path.join('patches', pn) for pn in patches]\n \n"},{"id":"112527","messageId":"20090428151025.27261.15964.stgit@pc1117.cambridge.arm.com","threadId":"19107","inReplyTo":"20090428150742.27261.19620.stgit@pc1117.cambridge.arm.com","subject":"[StGit PATCH 9/9] Use the default git colouring scheme rather than specific scripts","fromName":"Catalin Marinas","fromEmail":"catalin.marinas@arm.com","sentAt":"2009-04-28T15:10:25Z","receivedAt":"2009-04-28T15:10:25Z","isPatch":true,"sender":{"key":"catalin.marinas@arm.com","avatar":null},"body":"This patch adds the mechanism to check if the output is tty for the\ndiff and show commands and passes the --color option to git if the\ncolor.diff config option is set auto or true. The patch also changes the\ndefault pager to 'less -FRSX' from the diffcol.sh script.\n\nSigned-off-by: Catalin Marinas <catalin.marinas@gmail.com>\n---\n contrib/diffcol.sh       |   51 ----------------------------------------------\n examples/gitconfig       |    4 ++--\n setup.py                 |    3 +--\n stgit/commands/common.py |    8 +++++++\n stgit/commands/diff.py   |    2 ++\n stgit/commands/show.py   |    1 +\n stgit/config.py          |   10 +++++----\n 7 files changed, 19 insertions(+), 60 deletions(-)\n delete mode 100755 contrib/diffcol.sh\n\ndiff --git a/contrib/diffcol.sh b/contrib/diffcol.sh\ndeleted file mode 100755\nindex eecc87a..0000000\n--- a/contrib/diffcol.sh\n+++ /dev/null\n@@ -1,51 +0,0 @@\n-#!/bin/bash\n-\n-# Code copied from Quilt (http://savannah.nongnu.org/projects/quilt)\n-#\n-# Copyright 2006 - the Quilt authors\n-#\n-#  This script is free software; you can redistribute it and/or modify\n-#  it under the terms of the GNU General Public License version 2 as\n-#  published by the Free Software Foundation.\n-\n-setup_colors()\n-{\n-\tlocal C=\"diffhdr=1;36:diffhdradd=1;32:diffadd=32:diffhdrmod=1;35:diffmod=35:diffhdrrem=1;31:diffrem=31:diffhunk=36:diffctx=34:diffcctx=33:default=0\"\n-\t[ -n \"$DIFF_COLORS\" ] && C=\"$C:$DIFF_COLORS\"\n-\n-\tC=${C//=/=\\'$'\\e'[}\n-\tC=col${C//:/m\\'; col}m\\'\n-\t#coldefault=$(tput op)\n-\teval $C\n-}\n-\n-setup_colors\n-\n-gawk '{\n-\tif (/^(Index:|diff --git) /)\n-\t\tprint \"'$coldiffhdr'\" $0 \"'$coldefault'\"\n-\telse if (/^======*$/)\n-\t\tprint \"'$coldiffhdr'\" $0 \"'$coldefault'\"\n-\telse if (/^\\+\\+\\+/)\n-\t\tprint \"'$coldiffhdradd'\" $0 \"'$coldefault'\"\n-\telse if (/^\\*\\*\\*/)\n-\t\tprint \"'$coldiffhdrmod'\" $0 \"'$coldefault'\"\n-\telse if (/^---/)\n-\t\tprint \"'$coldiffhdrrem'\" $0 \"'$coldefault'\"\n-\telse if (/^(\\+|new( file)? mode )/)\n-\t\tprint \"'$coldiffadd'\" $0 \"'$coldefault'\"\n-\telse if (/^(-|(deleted file|old) mode )/)\n-\t\tprint \"'$coldiffrem'\" $0 \"'$coldefault'\"\n-\telse if (/^!/)\n-\t\tprint \"'$coldiffmod'\" $0 \"'$coldefault'\"\n-\telse if (/^@@ \\-[0-9]+(,[0-9]+)? \\+[0-9]+(,[0-9]+)? @@/)\n-\t\tprint gensub(/^(@@[^@]*@@)([ \\t]*)(.*)/,\n-\t\t\t\"'$coldiffhunk'\" \"\\\\1\" \"'$coldefault'\" \\\n-\t\t\t\"\\\\2\" \\\n-\t\t\t\"'$coldiffctx'\" \"\\\\3\" \"'$coldefault'\", \"\")\n-\telse if (/^\\*\\*\\*\\*\\*\\*\\*\\*\\*\\*\\*\\*\\*\\*\\*/)\n-\t\tprint \"'$coldiffcctx'\" $0 \"'$coldefault'\"\n-\telse {\n-\t\tprint\n-\t}\n-}' $1 | less -R -S\ndiff --git a/examples/gitconfig b/examples/gitconfig\nindex f6e3a79..e235e14 100644\n--- a/examples/gitconfig\n+++ b/examples/gitconfig\n@@ -42,8 +42,8 @@\n \t#editor = /usr/bin/vi\n \n \t# this value overrides the default PAGER environment variable\n-\t#pager = ~/share/stgit/contrib/diffcol.sh\n-\t#pager = filterdiff --annotate | colordiff | less -FRX\n+\t#pager = less -FRSX\n+\t#pager = filterdiff --annotate | colordiff | less -FRSX\n \n \t# GIT pull and fetch commands (should take the same arguments as\n \t# git fetch or git pull).  By default:\ndiff --git a/setup.py b/setup.py\nindex fb67958..73ce2e5 100755\n--- a/setup.py\n+++ b/setup.py\n@@ -58,8 +58,7 @@ def __run_setup():\n             ('share/stgit/templates', glob.glob('templates/*.tmpl')),\n             ('share/stgit/examples', glob.glob('examples/*.tmpl')),\n             ('share/stgit/examples', ['examples/gitconfig']),\n-            ('share/stgit/contrib', ['contrib/diffcol.sh',\n-                                     'contrib/stgbashprompt.sh']),\n+            ('share/stgit/contrib', ['contrib/stgbashprompt.sh']),\n             ('share/stgit/completion', ['stgit-completion.bash'])\n             ])\n \ndiff --git a/stgit/commands/common.py b/stgit/commands/common.py\nindex 6bb3685..e46412e 100644\n--- a/stgit/commands/common.py\n+++ b/stgit/commands/common.py\n@@ -83,6 +83,14 @@ def git_commit(name, repository, branch_name = None):\n     except libgit.RepositoryException:\n         raise CmdException('%s: Unknown patch or revision name' % name)\n \n+def color_diff_flags():\n+    \"\"\"Return the git flags for coloured diff output if the configuration and\n+    stdout allows.\"\"\"\n+    if sys.stdout.isatty() and config.get('color.diff') in ['true', 'auto']:\n+        return ['--color']\n+    else:\n+        return []\n+\n def check_local_changes():\n     if git.local_changes():\n         raise CmdException('local changes in the tree. Use \"refresh\" or'\ndiff --git a/stgit/commands/diff.py b/stgit/commands/diff.py\nindex 7d2f719..8b8ebe3 100644\n--- a/stgit/commands/diff.py\n+++ b/stgit/commands/diff.py\n@@ -72,6 +72,8 @@ def func(parser, options, args):\n         rev1 = 'HEAD'\n         rev2 = None\n \n+    if not options.stat:\n+        options.diff_flags.extend(color_diff_flags())\n     diff_str = git.diff(args, git_id(crt_series, rev1),\n                         rev2 and git_id(crt_series, rev2),\n                         diff_flags = options.diff_flags)\ndiff --git a/stgit/commands/show.py b/stgit/commands/show.py\nindex 895943a..b7a8aa9 100644\n--- a/stgit/commands/show.py\n+++ b/stgit/commands/show.py\n@@ -61,6 +61,7 @@ def func(parser, options, args):\n         # individual patches or commit ids\n         patches = args\n \n+    options.diff_flags.extend(color_diff_flags())\n     commit_ids = [git_id(crt_series, patch) for patch in patches]\n     commit_str = '\\n'.join([git.pretty_commit(commit_id,\n                                               flags = options.diff_flags)\ndiff --git a/stgit/config.py b/stgit/config.py\nindex efce097..4f16978 100644\n--- a/stgit/config.py\n+++ b/stgit/config.py\n@@ -37,7 +37,8 @@ class GitConfig:\n         'stgit.autoimerge':\t'no',\n         'stgit.keepoptimized':\t'no',\n         'stgit.extensions':\t'.ancestor .current .patched',\n-        'stgit.shortnr':\t '5'\n+        'stgit.shortnr': '5',\n+        'stgit.pager':  'less -FRSX'\n         }\n \n     __cache={}\n@@ -109,10 +110,9 @@ config=GitConfig()\n def config_setup():\n     global config\n \n-    # Set the PAGER environment to the config value (if any)\n-    pager = config.get('stgit.pager')\n-    if pager:\n-        os.environ['PAGER'] = pager\n+    # Set the PAGER environment to the config value if not already set\n+    if not 'PAGER' in os.environ:\n+        os.environ['PAGER'] = config.get('stgit.pager')\n     # FIXME: handle EDITOR the same way ?\n \n class ConfigOption:\n"},{"id":"112593","messageId":"20090429060448.GA18483@diana.vm.bytemark.co.uk","threadId":"19107","inReplyTo":"20090428150940.27261.65680.stgit@pc1117.cambridge.arm.com","subject":"Re: [StGit PATCH 1/9] Show \"Pushing <patch>...done\" when pushing a patch","fromName":"Karl Hasselström","fromEmail":"kha@treskal.com","sentAt":"2009-04-29T06:04:48Z","receivedAt":"2009-04-29T06:04:48Z","isPatch":true,"sender":{"key":"kha@treskal.com","avatar":"https://gravatar.com/avatar/f0120c734b5279b345075a28521e1ac66acb20c9913ffe9bf6ae97e53f7f3f13?d=mp&s=160"},"body":"On 2009-04-28 16:09:40 +0100, Catalin Marinas wrote:\n\n> My main reason is for the automatic invocation of the interactive\n> merge when I don't know what patch I have to deal with. The other\n> reasons is for people working over slow filesystems (NFS) where a\n> three-way merging may take a significant amount of time.\n\nI don't see any problems with this.\n\n-- \nKarl Hasselström, kha@treskal.com\n      www.treskal.com/kalle\n"},{"id":"112594","messageId":"20090429060700.GB18483@diana.vm.bytemark.co.uk","threadId":"19107","inReplyTo":"20090428150946.27261.60198.stgit@pc1117.cambridge.arm.com","subject":"Re: [StGit PATCH 2/9] Show some progress information when checking for upstream merges.","fromName":"Karl Hasselström","fromEmail":"kha@treskal.com","sentAt":"2009-04-29T06:07:00Z","receivedAt":"2009-04-29T06:07:00Z","isPatch":true,"sender":{"key":"kha@treskal.com","avatar":"https://gravatar.com/avatar/f0120c734b5279b345075a28521e1ac66acb20c9913ffe9bf6ae97e53f7f3f13?d=mp&s=160"},"body":"Looks good. (I hadn't even realized we were doing this only in the old\ninfrastructure.)\n\n-- \nKarl Hasselström, kha@treskal.com\n      www.treskal.com/kalle\n"},{"id":"112595","messageId":"20090429061338.GC18483@diana.vm.bytemark.co.uk","threadId":"19107","inReplyTo":"20090428150952.27261.5637.stgit@pc1117.cambridge.arm.com","subject":"Re: [StGit PATCH 3/9] Do not sleep after the last patch sent by e-mail","fromName":"Karl Hasselström","fromEmail":"kha@treskal.com","sentAt":"2009-04-29T06:13:38Z","receivedAt":"2009-04-29T06:13:38Z","isPatch":true,"sender":{"key":"kha@treskal.com","avatar":"https://gravatar.com/avatar/f0120c734b5279b345075a28521e1ac66acb20c9913ffe9bf6ae97e53f7f3f13?d=mp&s=160"},"body":"This is an improvement.\n\nAn somewhat related improvement would be to decouple the mail sending\nand interactive editing of cover letter and patch mails -- we don't\nreally need to wait five seconds before letting the user edit the next\npatch! (In fact, we should probably let her edit everything first, and\nthen ask \"Send? Y/N\" at the end. Or something. Maybe a menu with\noptions to edit cover letter, edit patches, send, save to mbox, read\nfrom mbox, and discard. But now we're getting into UI land. And most\nof this isn't StGit-specific anyway.)\n\n-- \nKarl Hasselström, kha@treskal.com\n      www.treskal.com/kalle\n"},{"id":"112596","messageId":"20090429062101.GD18483@diana.vm.bytemark.co.uk","threadId":"19107","inReplyTo":"20090428150957.27261.83658.stgit@pc1117.cambridge.arm.com","subject":"Re: [StGit PATCH 4/9] Convert 'clone' to the use stgit.lib","fromName":"Karl Hasselström","fromEmail":"kha@treskal.com","sentAt":"2009-04-29T06:21:01Z","receivedAt":"2009-04-29T06:21:01Z","isPatch":true,"sender":{"key":"kha@treskal.com","avatar":"https://gravatar.com/avatar/f0120c734b5279b345075a28521e1ac66acb20c9913ffe9bf6ae97e53f7f3f13?d=mp&s=160"},"body":"On 2009-04-28 16:09:57 +0100, Catalin Marinas wrote:\n\n> The patch also adds the stgit.lib.git.clone() function.\n\n>      if os.path.exists(local_dir):\n> -        raise CmdException, '\"%s\" exists. Remove it first' % local_dir\n> -\n> -    print 'Cloning \"%s\" into \"%s\"...' % (repository, local_dir)\n> +        raise common.CmdException, '\"%s\" exists. Remove it first' % local_dir\n\nAs recommended by PEP 8, consider using the \"raise Exc(args)\" syntax:\n\n    - When raising an exception, use \"raise ValueError('message')\" instead of\n      the older form \"raise ValueError, 'message'\".\n\n      The paren-using form is preferred because when the exception arguments\n      are long or include string formatting, you don't need to use line\n      continuation characters thanks to the containing parentheses.  The older\n      form will be removed in Python 3000.\n\n> +def clone(remote, local):\n> +    \"\"\"Clone a remote repository using 'git clone'.\"\"\"\n> +    run.Run('git', 'clone', remote, local).run()\n\nYou don't capture git's output here, but just let it through. Does\nthat look good in combination with the enclosing out.start() ...\n.done() stuff?\n\n-- \nKarl Hasselström, kha@treskal.com\n      www.treskal.com/kalle\n"},{"id":"112597","messageId":"20090429062749.GE18483@diana.vm.bytemark.co.uk","threadId":"19107","inReplyTo":"20090428151003.27261.72531.stgit@pc1117.cambridge.arm.com","subject":"Re: [StGit PATCH 5/9] Convert 'hide' to the lib infrastructure","fromName":"Karl Hasselström","fromEmail":"kha@treskal.com","sentAt":"2009-04-29T06:27:49Z","receivedAt":"2009-04-29T06:27:49Z","isPatch":true,"sender":{"key":"kha@treskal.com","avatar":"https://gravatar.com/avatar/f0120c734b5279b345075a28521e1ac66acb20c9913ffe9bf6ae97e53f7f3f13?d=mp&s=160"},"body":"On 2009-04-28 16:10:03 +0100, Catalin Marinas wrote:\n\n> -args = [argparse.patch_range(argparse.applied_patches,\n> -                             argparse.unapplied_patches)]\n> +args = [argparse.patch_range(argparse.unapplied_patches)]\n\nWhy not simply allow all patches? reorder_patches() below will happily\npop unapplied patches before hiding them IIRC, and for already hidden\npatches you could just say \"already hidden\".\n\nHmm, but this is for the tab completion, so I guess we'd only want the\napplied and unapplied patches here.\n\n> +    patches = common.parse_patches(args, trans.all_patches)\n> +    for p in patches:\n> +        if p in trans.applied:\n> +            raise common.CmdException('Cannot hide applied patch \"%s\"' % p)\n> +        elif p in trans.hidden:\n> +            raise common.CmdException('Patch \"%s\" already hidden' % p)\n> +\n> +    applied = list(trans.applied)\n> +    unapplied = [p for p in trans.unapplied if not p in set(patches)]\n> +    hidden = patches + trans.hidden\n> +\n> +    trans.reorder_patches(applied, unapplied, hidden)\n> +    return trans.run()\n\nAs I said,\n\n  * Why not simply allow hiding of applied patches?\n\n  * Hiding a hidden patch should probably be a warning (if that), not\n    an error.\n\nOtherwise it looks good.\n\n-- \nKarl Hasselström, kha@treskal.com\n      www.treskal.com/kalle\n"},{"id":"112598","messageId":"20090429062900.GF18483@diana.vm.bytemark.co.uk","threadId":"19107","inReplyTo":"20090428151008.27261.10237.stgit@pc1117.cambridge.arm.com","subject":"Re: [StGit PATCH 6/9] Convert 'unhide' to the lib infrastructure","fromName":"Karl Hasselström","fromEmail":"kha@treskal.com","sentAt":"2009-04-29T06:29:00Z","receivedAt":"2009-04-29T06:29:00Z","isPatch":true,"sender":{"key":"kha@treskal.com","avatar":"https://gravatar.com/avatar/f0120c734b5279b345075a28521e1ac66acb20c9913ffe9bf6ae97e53f7f3f13?d=mp&s=160"},"body":"Looks good.\n\n-- \nKarl Hasselström, kha@treskal.com\n      www.treskal.com/kalle\n"},{"id":"112599","messageId":"20090429063309.GG18483@diana.vm.bytemark.co.uk","threadId":"19107","inReplyTo":"20090428151014.27261.18502.stgit@pc1117.cambridge.arm.com","subject":"Re: [StGit PATCH 7/9] Reinstate the --annotate option for refresh","fromName":"Karl Hasselström","fromEmail":"kha@treskal.com","sentAt":"2009-04-29T06:33:09Z","receivedAt":"2009-04-29T06:33:09Z","isPatch":true,"sender":{"key":"kha@treskal.com","avatar":"https://gravatar.com/avatar/f0120c734b5279b345075a28521e1ac66acb20c9913ffe9bf6ae97e53f7f3f13?d=mp&s=160"},"body":"On 2009-04-28 16:10:14 +0100, Catalin Marinas wrote:\n\n> It is sometimes useful to add some notes to the log entry when a\n> patch was refreshed. This option was dropped when the command was\n> updated to the new infrastructure as there was no logging support at\n> that time.\n\nIt looks like if you get a conflict during the refresh (such as when\ndoing refresh -p, and we can't reorder the patches) the annotation\nwill be dropped. That could presumably be fixed by tacking it on to\nthe log message for the creation of the temp patch as well.\n\nBut I don't know if it's that important. I've never felt the need for\nthis feature myself.\n\n-- \nKarl Hasselström, kha@treskal.com\n      www.treskal.com/kalle\n"},{"id":"112601","messageId":"20090429063539.GH18483@diana.vm.bytemark.co.uk","threadId":"19107","inReplyTo":"20090428151020.27261.27456.stgit@pc1117.cambridge.arm.com","subject":"Re: [StGit PATCH 8/9] Add the log --clear option","fromName":"Karl Hasselström","fromEmail":"kha@treskal.com","sentAt":"2009-04-29T06:35:39Z","receivedAt":"2009-04-29T06:35:39Z","isPatch":true,"sender":{"key":"kha@treskal.com","avatar":"https://gravatar.com/avatar/f0120c734b5279b345075a28521e1ac66acb20c9913ffe9bf6ae97e53f7f3f13?d=mp&s=160"},"body":"On 2009-04-28 16:10:20 +0100, Catalin Marinas wrote:\n\n> This option allows the clearing of the log history which sometimes\n> may get too large.\n\nWow, I didn't realize we already had all the pieces for doing this.\n\nOf course, what we'd _really_ want is to delete the log except for the\nlast N days, or the last N entries. :-) That's gonna be a bit more\nwork, though, and this is an excellent step in the right direction.\n\n-- \nKarl Hasselström, kha@treskal.com\n      www.treskal.com/kalle\n"},{"id":"112602","messageId":"20090429064331.GI18483@diana.vm.bytemark.co.uk","threadId":"19107","inReplyTo":"20090428151025.27261.15964.stgit@pc1117.cambridge.arm.com","subject":"Re: [StGit PATCH 9/9] Use the default git colouring scheme rather than specific scripts","fromName":"Karl Hasselström","fromEmail":"kha@treskal.com","sentAt":"2009-04-29T06:43:31Z","receivedAt":"2009-04-29T06:43:31Z","isPatch":true,"sender":{"key":"kha@treskal.com","avatar":"https://gravatar.com/avatar/f0120c734b5279b345075a28521e1ac66acb20c9913ffe9bf6ae97e53f7f3f13?d=mp&s=160"},"body":"On 2009-04-28 16:10:25 +0100, Catalin Marinas wrote:\n\n> This patch adds the mechanism to check if the output is tty for the\n> diff and show commands and passes the --color option to git if the\n> color.diff config option is set auto or true. The patch also changes\n> the default pager to 'less -FRSX' from the diffcol.sh script.\n\nSeems like a nice improvement.\n\n> +    # Set the PAGER environment to the config value if not already set\n> +    if not 'PAGER' in os.environ:\n> +        os.environ['PAGER'] = config.get('stgit.pager')\n\nYou can replace these two lines with\n\n  os.environ.setdefault('PAGER', config.get('stgit.pager'))\n\nThe only downside is that config.get() will be evaluated (and the\nresult discarded) even if PAGER _is_ set in the environment. But\nconfig.get() should be dirt cheap, because we should be reading in all\nthe config values at once the first time we need one of them. But as I\nrecall we don't currently do that, so my one-liner might not be so\nclever after all ...\n\n-- \nKarl Hasselström, kha@treskal.com\n      www.treskal.com/kalle\n"},{"id":"112620","messageId":"2009-04-29-13-48-29+trackit+sam@rfc1149.net","threadId":"19107","inReplyTo":"20090429064331.GI18483@diana.vm.bytemark.co.uk","subject":"Re: [StGit PATCH 9/9] Use the default git colouring scheme rather than specific scripts","fromName":"Samuel Tardieu","fromEmail":"sam@rfc1149.net","sentAt":"2009-04-29T11:48:29Z","receivedAt":"2009-04-29T11:48:29Z","isPatch":true,"sender":{"key":"sam@rfc1149.net","avatar":"https://avatars.githubusercontent.com/u/44656?v=4"},"body":"Author: Samuel Tardieu <sam@rfc1149.net>\nDate:   Wed Apr 29 13:45:06 2009 +0200\n\nLoad the whole config at once and cache it for future use\n\nThe whole configuration files are read using\n\n  git config --list --null\n\nand cached for future lookups.\n\nSigned-off-by: Samuel Tardieu <sam@rfc1149.net>\n---\n>>>>> \"Karl\" == Karl Hasselström <kha@treskal.com> writes:\n\nKarl> But config.get() should be dirt cheap, because we should be\nKarl> reading in all the config values at once the first time we need\nKarl> one of them. But as I recall we don't currently do that, so my\nKarl> one-liner might not be so clever after all ...\n\nSomething like this may be useful then.\n\n  Sam\n\ndiff --git a/stgit/config.py b/stgit/config.py\nindex dbca5fb..c40756c 100644\n--- a/stgit/config.py\n+++ b/stgit/config.py\n@@ -40,25 +40,31 @@ class GitConfig:\n         'stgit.shortnr':\t '5'\n         }\n \n-    __cache={}\n+    __cache = None\n+\n+    def load(self):\n+        \"\"\"Load the whole configuration in __cache unless it has been\n+        done already.\"\"\"\n+        if self.__cache is not None:\n+            return\n+        self.__cache = {}\n+        lines = Run('git', 'config', '--list', '--null').raw_output()\n+        for line in filter(None, lines.split('\\0')):\n+            key, value = line.split('\\n', 1)\n+            self.__cache.setdefault(key, []).append(value)\n \n     def get(self, name):\n-        if self.__cache.has_key(name):\n-            return self.__cache[name]\n-        try:\n-            value = Run('git', 'config', '--get', name).output_one_line()\n-        except RunException:\n-            value = self.__defaults.get(name, None)\n-        self.__cache[name] = value\n-        return value\n+        self.load()\n+        if name not in self.__cache:\n+            self.__cache[name] = [self.__defaults.get(name, None)]\n+        return self.__cache[name][0]\n \n     def getall(self, name):\n-        if self.__cache.has_key(name):\n+        self.load()\n+        try:\n             return self.__cache[name]\n-        values = Run('git', 'config', '--get-all', name\n-                     ).returns([0, 1]).output_lines()\n-        self.__cache[name] = values\n-        return values\n+        except KeyError:\n+            return []\n \n     def getint(self, name):\n         value = self.get(name)\n"},{"id":"112621","messageId":"2009-04-29-13-56-16+trackit+sam@rfc1149.net","threadId":"19107","inReplyTo":"2009-04-29-13-48-29+trackit+sam@rfc1149.net","subject":"Re: [StGit PATCH 9/9] Use the default git colouring scheme rather than specific scripts","fromName":"Samuel Tardieu","fromEmail":"sam@rfc1149.net","sentAt":"2009-04-29T11:56:16Z","receivedAt":"2009-04-29T11:56:16Z","isPatch":true,"sender":{"key":"sam@rfc1149.net","avatar":"https://avatars.githubusercontent.com/u/44656?v=4"},"body":"Karl> But config.get() should be dirt cheap, because we should be\nKarl> reading in all the config values at once the first time we need\nKarl> one of them. But as I recall we don't currently do that, so my\nKarl> one-liner might not be so clever after all ...\n\nSam> Something like this may be useful then.\n\nBtw, the patch is against kha/experimental.\n\n  Sam\n-- \nSamuel Tardieu -- sam@rfc1149.net -- http://www.rfc1149.net/\n"},{"id":"112637","messageId":"20090429142556.GA26504@diana.vm.bytemark.co.uk","threadId":"19107","inReplyTo":"2009-04-29-13-48-29+trackit+sam@rfc1149.net","subject":"Re: [StGit PATCH 9/9] Use the default git colouring scheme rather than specific scripts","fromName":"Karl Hasselström","fromEmail":"kha@treskal.com","sentAt":"2009-04-29T14:25:56Z","receivedAt":"2009-04-29T14:25:56Z","isPatch":true,"sender":{"key":"kha@treskal.com","avatar":"https://gravatar.com/avatar/f0120c734b5279b345075a28521e1ac66acb20c9913ffe9bf6ae97e53f7f3f13?d=mp&s=160"},"body":"On 2009-04-29 13:48:29 +0200, Samuel Tardieu wrote:\n\n> Something like this may be useful then.\n\nYes, exactly.\n\n-- \nKarl Hasselström, kha@treskal.com\n      www.treskal.com/kalle\n"},{"id":"112972","messageId":"49FEE41F.4010006@ruby.dti.ne.jp","threadId":"19107","inReplyTo":"20090428151025.27261.15964.stgit@pc1117.cambridge.arm.com","subject":"Re: [StGit PATCH 9/9] Use the default git colouring scheme rather than specific scripts","fromName":"Shinya Kuribayashi","fromEmail":"skuribay@ruby.dti.ne.jp","sentAt":"2009-05-04T12:48:31Z","receivedAt":"2009-05-04T12:48:31Z","isPatch":true,"sender":{"key":"skuribay@ruby.dti.ne.jp","avatar":null},"body":"Hi,\n\nCatalin Marinas wrote:\n> This patch adds the mechanism to check if the output is tty for the\n> diff and show commands and passes the --color option to git if the\n> color.diff config option is set auto or true. The patch also changes the\n> default pager to 'less -FRSX' from the diffcol.sh script.\n> \n> Signed-off-by: Catalin Marinas <catalin.marinas@gmail.com>\n\nCool.\n\n> diff --git a/stgit/commands/common.py b/stgit/commands/common.py\n> index 6bb3685..e46412e 100644\n> --- a/stgit/commands/common.py\n> +++ b/stgit/commands/common.py\n> @@ -83,6 +83,14 @@ def git_commit(name, repository, branch_name = None):\n>      except libgit.RepositoryException:\n>          raise CmdException('%s: Unknown patch or revision name' % name)\n>  \n> +def color_diff_flags():\n> +    \"\"\"Return the git flags for coloured diff output if the configuration and\n> +    stdout allows.\"\"\"\n> +    if sys.stdout.isatty() and config.get('color.diff') in ['true', 'auto']:\n> +        return ['--color']\n> +    else:\n> +        return []\n> +\n>  def check_local_changes():\n>      if git.local_changes():\n>          raise CmdException('local changes in the tree. Use \"refresh\" or'\n\nJunio introduces `color.ui=auto' as one of base settings in his recent\nJapanese article for Git newbies:\n\nhttp://gitster.livejournal.com/2009/04/24/\n\nIs color.ui worth supporting in color_diff_flags()?, or simply having \nadditional color.diff would be better?\n\n> diff --git a/stgit/config.py b/stgit/config.py\n> index efce097..4f16978 100644\n> --- a/stgit/config.py\n> +++ b/stgit/config.py\n> @@ -37,7 +37,8 @@ class GitConfig:\n>          'stgit.autoimerge':\t'no',\n>          'stgit.keepoptimized':\t'no',\n>          'stgit.extensions':\t'.ancestor .current .patched',\n> -        'stgit.shortnr':\t '5'\n> +        'stgit.shortnr': '5',\n> +        'stgit.pager':  'less -FRSX'\n>          }\n>  \n>      __cache={}\n\nWrong indentation? :-)\n\n\nShinya\n"},{"id":"113799","messageId":"b0943d9e0905130908x6ce569b7gddfc7c152989a618@mail.gmail.com","threadId":"19107","inReplyTo":"20090429062749.GE18483@diana.vm.bytemark.co.uk","subject":"Re: [StGit PATCH 5/9] Convert 'hide' to the lib infrastructure","fromName":"Catalin Marinas","fromEmail":"catalin.marinas@gmail.com","sentAt":"2009-05-13T16:08:02Z","receivedAt":"2009-05-13T16:08:02Z","isPatch":true,"sender":{"key":"catalin.marinas@gmail.com","avatar":null},"body":"2009/4/29 Karl Hasselström <kha@treskal.com>:\n> On 2009-04-28 16:10:03 +0100, Catalin Marinas wrote:\n>\n>> -args = [argparse.patch_range(argparse.applied_patches,\n>> -                             argparse.unapplied_patches)]\n>> +args = [argparse.patch_range(argparse.unapplied_patches)]\n>\n> Why not simply allow all patches? reorder_patches() below will happily\n> pop unapplied patches before hiding them IIRC, and for already hidden\n> patches you could just say \"already hidden\".\n>\n> Hmm, but this is for the tab completion, so I guess we'd only want the\n> applied and unapplied patches here.\n\nI fixed that in the proposed branch but I was to slow on sending e-mails.\n\n> As I said,\n>\n>  * Why not simply allow hiding of applied patches?\n>\n>  * Hiding a hidden patch should probably be a warning (if that), not\n>    an error.\n\nFixed this as well.\n\n-- \nCatalin\n"},{"id":"113801","messageId":"b0943d9e0905130910w35a5382ai3d89751d7d8b0c48@mail.gmail.com","threadId":"19107","inReplyTo":"20090429062101.GD18483@diana.vm.bytemark.co.uk","subject":"Re: [StGit PATCH 4/9] Convert 'clone' to the use stgit.lib","fromName":"Catalin Marinas","fromEmail":"catalin.marinas@gmail.com","sentAt":"2009-05-13T16:10:08Z","receivedAt":"2009-05-13T16:10:08Z","isPatch":true,"sender":{"key":"catalin.marinas@gmail.com","avatar":null},"body":"2009/4/29 Karl Hasselström <kha@treskal.com>:\n> On 2009-04-28 16:09:57 +0100, Catalin Marinas wrote:\n>> +def clone(remote, local):\n>> +    \"\"\"Clone a remote repository using 'git clone'.\"\"\"\n>> +    run.Run('git', 'clone', remote, local).run()\n>\n> You don't capture git's output here, but just let it through. Does\n> that look good in combination with the enclosing out.start() ...\n> .done() stuff?\n\nI actually dropped the out.*() entirely as git already prints enough\ninformation.\n\n-- \nCatalin\n"},{"id":"115007","messageId":"b0943d9e0905290522l377c8f35h7f442b183cb7c7d2@mail.gmail.com","threadId":"19107","inReplyTo":"49FEE41F.4010006@ruby.dti.ne.jp","subject":"Re: [StGit PATCH 9/9] Use the default git colouring scheme rather than specific scripts","fromName":"Catalin Marinas","fromEmail":"catalin.marinas@gmail.com","sentAt":"2009-05-29T12:22:48Z","receivedAt":"2009-05-29T12:22:48Z","isPatch":true,"sender":{"key":"catalin.marinas@gmail.com","avatar":null},"body":"2009/5/4 Shinya Kuribayashi <skuribay@ruby.dti.ne.jp>:\n> Catalin Marinas wrote:\n>>  +def color_diff_flags():\n>> +    \"\"\"Return the git flags for coloured diff output if the configuration\n>> and\n>> +    stdout allows.\"\"\"\n>> +    if sys.stdout.isatty() and config.get('color.diff') in ['true',\n>> 'auto']:\n>> +        return ['--color']\n>> +    else:\n>> +        return []\n>> +\n>>  def check_local_changes():\n>>     if git.local_changes():\n>>         raise CmdException('local changes in the tree. Use \"refresh\" or'\n>\n> Junio introduces `color.ui=auto' as one of base settings in his recent\n> Japanese article for Git newbies:\n\nThat's probably a better option. I changed the patch to this (only\nshowing the relevant parts):\n\n--- a/stgit/commands/common.py\n+++ b/stgit/commands/common.py\n@@ -97,6 +97,15 @@ def git_commit(name, repository, branch_name = None):\n     except libgit.RepositoryException:\n         raise CmdException('%s: Unknown patch or revision name' % name)\n\n+def color_diff_flags():\n+    \"\"\"Return the git flags for coloured diff output if the configuration and\n+    stdout allows.\"\"\"\n+    stdout_is_tty = (sys.stdout.isatty() and 'true') or 'false'\n+    if config.get_colorbool('color.diff', stdout_is_tty) == 'true':\n+        return ['--color']\n+    else:\n+        return []\n+\n def check_local_changes():\n     if git.local_changes():\n         raise CmdException('local changes in the tree. Use \"refresh\" or'\n\n--- a/stgit/config.py\n+++ b/stgit/config.py\n@@ -109,16 +110,18 @@ class GitConfig:\n             if m:\n                 result.append(m.group(1))\n         return result\n+\n+    def get_colorbool(self, name, stdout_is_tty):\n+        \"\"\"Invoke 'git config --get-colorbool' and return the result.\"\"\"\n+        return Run('git', 'config', '--get-colorbool', name,\n+                   stdout_is_tty).output_one_line()\n\n config=GitConfig()\n\n>> diff --git a/stgit/config.py b/stgit/config.py\n>> index efce097..4f16978 100644\n>> --- a/stgit/config.py\n>> +++ b/stgit/config.py\n>> @@ -37,7 +37,8 @@ class GitConfig:\n>>         'stgit.autoimerge':    'no',\n>>         'stgit.keepoptimized': 'no',\n>>         'stgit.extensions':    '.ancestor .current .patched',\n>> -        'stgit.shortnr':        '5'\n>> +        'stgit.shortnr': '5',\n>> +        'stgit.pager':  'less -FRSX'\n>>         }\n>>       __cache={}\n>\n> Wrong indentation? :-)\n\nThe indentation is right, only that in the past there was a tab left\nwhich I removed with this occasion.\n\n-- \nCatalin\n"},{"id":"115061","messageId":"4A207F8B.9060805@pobox.com","threadId":"19107","inReplyTo":"b0943d9e0905290522l377c8f35h7f442b183cb7c7d2@mail.gmail.com","subject":"Re: [StGit PATCH 9/9] Use the default git colouring scheme rather than specific scripts","fromName":"Shinya Kuribayashi","fromEmail":"skuribay@pobox.com","sentAt":"2009-05-30T00:36:27Z","receivedAt":"2009-05-30T00:36:27Z","isPatch":true,"sender":{"key":"skuribay@pobox.com","avatar":null},"body":"Catalin Marinas wrote:\n> That's probably a better option. I changed the patch to this (only\n> showing the relevant parts):\n> \n> --- a/stgit/commands/common.py\n> +++ b/stgit/commands/common.py\n> @@ -97,6 +97,15 @@ def git_commit(name, repository, branch_name = None):\n>      except libgit.RepositoryException:\n>          raise CmdException('%s: Unknown patch or revision name' % name)\n> \n> +def color_diff_flags():\n> +    \"\"\"Return the git flags for coloured diff output if the configuration and\n> +    stdout allows.\"\"\"\n> +    stdout_is_tty = (sys.stdout.isatty() and 'true') or 'false'\n> +    if config.get_colorbool('color.diff', stdout_is_tty) == 'true':\n> +        return ['--color']\n> +    else:\n> +        return []\n> +\n>  def check_local_changes():\n>      if git.local_changes():\n>          raise CmdException('local changes in the tree. Use \"refresh\" or'\n> \n> --- a/stgit/config.py\n> +++ b/stgit/config.py\n> @@ -109,16 +110,18 @@ class GitConfig:\n>              if m:\n>                  result.append(m.group(1))\n>          return result\n> +\n> +    def get_colorbool(self, name, stdout_is_tty):\n> +        \"\"\"Invoke 'git config --get-colorbool' and return the result.\"\"\"\n> +        return Run('git', 'config', '--get-colorbool', name,\n> +                   stdout_is_tty).output_one_line()\n> \n>  config=GitConfig()\n\nProposed branch now works for me only with color.ui=auto.\n\nThanks!\n--\nShinya Kuribayashi\n"}]}