{"thread":{"id":"7253","subject":"[StGIT PATCH 00/10] Various fixes and improvements","startedAt":"2007-03-15T00:26:29Z","lastAt":"2007-03-15T00:27:20Z","messageCount":11,"participants":["Yann Dirson"],"isPatch":true,"patchVersion":1,"patchTotal":10},"messages":[{"id":"37134","messageId":"20070315001808.9094.68529.stgit@gandelf.nowhere.earth","threadId":"7253","inReplyTo":null,"subject":"[StGIT PATCH 00/10] Various fixes and improvements","fromName":"Yann Dirson","fromEmail":"ydirson@altern.org","sentAt":"2007-03-15T00:26:29Z","receivedAt":"2007-03-15T00:26:29Z","isPatch":true,"sender":{"key":"ydirson@altern.org","avatar":"https://avatars.githubusercontent.com/u/1190950?v=4"},"body":"I found a couple of issues involving stack deletion, here are fixes\nfor the most annoying ones.\nAlso includes some small cleanups involving parent information, as\nwell as mostly-unrelated small improvements gathered while hacking on\nthe other patches.\n\n\nNote: since I have seen the patch entitled 'git-fetch: Support the\nlocal remote \".\"', I'm much less sure about my patch that stops\nrecording this type of information (the \"Stop recording\nbranch.*.remote to '.' for local parents.\" one), but I add it\nnevertheless, mostly for discussion.\n\n-- \nYann Dirson    <ydirson@altern.org> |\nDebian-related: <dirson@debian.org> |   Support Debian GNU/Linux:\n                                    |  Freedom, Power, Stability, Gratis\n     http://ydirson.free.fr/        | Check <http://www.debian.org/>\n"},{"id":"37136","messageId":"20070315002634.9094.6274.stgit@gandelf.nowhere.earth","threadId":"7253","inReplyTo":"20070315001808.9094.68529.stgit@gandelf.nowhere.earth","subject":"[PATCH 01/10] Fix stack deletion when orig-base is present.","fromName":"Yann Dirson","fromEmail":"ydirson@altern.org","sentAt":"2007-03-15T00:26:34Z","receivedAt":"2007-03-15T00:26:34Z","isPatch":true,"sender":{"key":"ydirson@altern.org","avatar":"https://avatars.githubusercontent.com/u/1190950?v=4"},"body":"\nThe introduction of the orig-base file makes the stack deletion fail\nto remove the stack's directory, leaving the stack in a zombie state,\nwhere attempting to recreate it was refused because of the directory\nalready existing, but attempting to delete it failed since the applied\nand unapplied files were not found.\n\nSigned-off-by: Yann Dirson <ydirson@altern.org>\n---\n\n stgit/stack.py |    2 ++\n 1 files changed, 2 insertions(+), 0 deletions(-)\n\ndiff --git a/stgit/stack.py b/stgit/stack.py\nindex feb77e3..8a63102 100644\n--- a/stgit/stack.py\n+++ b/stgit/stack.py\n@@ -676,6 +676,8 @@ class Series(StgitObject):\n                 os.remove(self.__current_file)\n             if os.path.exists(self.__descr_file):\n                 os.remove(self.__descr_file)\n+            if os.path.exists(self._dir()+'/orig-base'):\n+                os.remove(self._dir()+'/orig-base')\n             if not os.listdir(self.__patch_dir):\n                 os.rmdir(self.__patch_dir)\n             else:\n"},{"id":"37135","messageId":"20070315002639.9094.82423.stgit@gandelf.nowhere.earth","threadId":"7253","inReplyTo":"20070315001808.9094.68529.stgit@gandelf.nowhere.earth","subject":"[PATCH 02/10] Fix diagnostic messages on patch deletion and simplify others.","fromName":"Yann Dirson","fromEmail":"ydirson@altern.org","sentAt":"2007-03-15T00:26:39Z","receivedAt":"2007-03-15T00:26:39Z","isPatch":true,"sender":{"key":"ydirson@altern.org","avatar":"https://avatars.githubusercontent.com/u/1190950?v=4"},"body":"\nAlso make use standard os.removedirs(), allowing for the same\nsimplification.\n\nSigned-off-by: Yann Dirson <ydirson@altern.org>\n---\n\n stgit/stack.py |   15 ++++++++-------\n 1 files changed, 8 insertions(+), 7 deletions(-)\n\ndiff --git a/stgit/stack.py b/stgit/stack.py\nindex 8a63102..8fdaf2c 100644\n--- a/stgit/stack.py\n+++ b/stgit/stack.py\n@@ -571,7 +571,7 @@ class Series(StgitObject):\n                 os.rmdir(self.__patch_dir)\n                 print 'done'\n             else:\n-                print 'Patch directory %s is not empty.' % self.__name\n+                print 'Patch directory %s is not empty.' % self.__patch_dir\n \n             self.__patch_dir = self._dir()\n \n@@ -678,18 +678,19 @@ class Series(StgitObject):\n                 os.remove(self.__descr_file)\n             if os.path.exists(self._dir()+'/orig-base'):\n                 os.remove(self._dir()+'/orig-base')\n+\n             if not os.listdir(self.__patch_dir):\n                 os.rmdir(self.__patch_dir)\n             else:\n-                print 'Patch directory %s is not empty.' % self.__name\n+                print 'Patch directory %s is not empty.' % self.__patch_dir\n+\n             if not os.listdir(self._dir()):\n-                remove_dirs(os.path.join(self.__base_dir, 'patches'),\n-                            self.__name)\n+                os.removedirs(self._dir())\n             else:\n-                print 'Series directory %s is not empty.' % self.__name\n+                raise StackException, 'Series directory %s is not empty.' % self._dir()\n+\n             if not os.listdir(self.__refs_dir):\n-                remove_dirs(os.path.join(self.__base_dir, 'refs', 'patches'),\n-                            self.__name)\n+                os.removedirs(self.__refs_dir)\n             else:\n                 print 'Refs directory %s is not empty.' % self.__refs_dir\n \n"},{"id":"37137","messageId":"20070315002644.9094.83602.stgit@gandelf.nowhere.earth","threadId":"7253","inReplyTo":"20070315001808.9094.68529.stgit@gandelf.nowhere.earth","subject":"[PATCH 03/10] Make use exception raised by removedirs.","fromName":"Yann Dirson","fromEmail":"ydirson@altern.org","sentAt":"2007-03-15T00:26:44Z","receivedAt":"2007-03-15T00:26:44Z","isPatch":true,"sender":{"key":"ydirson@altern.org","avatar":"https://avatars.githubusercontent.com/u/1190950?v=4"},"body":"\n\n\nSigned-off-by: Yann Dirson <ydirson@altern.org>\n---\n\n stgit/stack.py |    8 ++++----\n 1 files changed, 4 insertions(+), 4 deletions(-)\n\ndiff --git a/stgit/stack.py b/stgit/stack.py\nindex 8fdaf2c..ec75507 100644\n--- a/stgit/stack.py\n+++ b/stgit/stack.py\n@@ -684,14 +684,14 @@ class Series(StgitObject):\n             else:\n                 print 'Patch directory %s is not empty.' % self.__patch_dir\n \n-            if not os.listdir(self._dir()):\n+            try:\n                 os.removedirs(self._dir())\n-            else:\n+            except OSError:\n                 raise StackException, 'Series directory %s is not empty.' % self._dir()\n \n-            if not os.listdir(self.__refs_dir):\n+            try:\n                 os.removedirs(self.__refs_dir)\n-            else:\n+            except OSError:\n                 print 'Refs directory %s is not empty.' % self.__refs_dir\n \n         if os.path.exists(self.__base_file):\n"},{"id":"37138","messageId":"20070315002649.9094.6314.stgit@gandelf.nowhere.earth","threadId":"7253","inReplyTo":"20070315001808.9094.68529.stgit@gandelf.nowhere.earth","subject":"[PATCH 04/10] Drop utils.remove_dirs() in favor of os.removedirs().","fromName":"Yann Dirson","fromEmail":"ydirson@altern.org","sentAt":"2007-03-15T00:26:50Z","receivedAt":"2007-03-15T00:26:50Z","isPatch":true,"sender":{"key":"ydirson@altern.org","avatar":"https://avatars.githubusercontent.com/u/1190950?v=4"},"body":"\n\n\nSigned-off-by: Yann Dirson <ydirson@altern.org>\n---\n\n stgit/utils.py |   24 ++++++++++--------------\n 1 files changed, 10 insertions(+), 14 deletions(-)\n\ndiff --git a/stgit/utils.py b/stgit/utils.py\nindex bfe7797..d04d077 100644\n--- a/stgit/utils.py\n+++ b/stgit/utils.py\n@@ -116,24 +116,16 @@ def strip_suffix(suffix, string):\n     assert string.endswith(suffix)\n     return string[:-len(suffix)]\n \n-def remove_dirs(basedir, dirs):\n-    \"\"\"Starting at join(basedir, dirs), remove the directory if empty,\n-    and try the same with its parent, until we find a nonempty\n-    directory or reach basedir.\"\"\"\n-    path = dirs\n-    while path:\n-        try:\n-            os.rmdir(os.path.join(basedir, path))\n-        except OSError:\n-            return # can't remove nonempty directory\n-        path = os.path.dirname(path)\n-\n def remove_file_and_dirs(basedir, file):\n     \"\"\"Remove join(basedir, file), and then remove the directory it\n     was in if empty, and try the same with its parent, until we find a\n     nonempty directory or reach basedir.\"\"\"\n     os.remove(os.path.join(basedir, file))\n-    remove_dirs(basedir, os.path.dirname(file))\n+    try:\n+        os.removedirs(os.path.join(basedir, os.path.dirname(file)))\n+    except OSError:\n+        # file's parent dir may not be empty after removal\n+        pass\n \n def create_dirs(directory):\n     \"\"\"Create the given directory, if the path doesn't already exist.\"\"\"\n@@ -152,7 +144,11 @@ def rename(basedir, file1, file2):\n     full_file2 = os.path.join(basedir, file2)\n     create_dirs(os.path.dirname(full_file2))\n     os.rename(os.path.join(basedir, file1), full_file2)\n-    remove_dirs(basedir, os.path.dirname(file1))\n+    try:\n+        os.removedirs(os.path.join(basedir, os.path.dirname(file1)))\n+    except OSError:\n+        # file1's parent dir may not be empty after move\n+        pass\n \n class EditorException(Exception):\n     pass\n"},{"id":"37139","messageId":"20070315002655.9094.26346.stgit@gandelf.nowhere.earth","threadId":"7253","inReplyTo":"20070315001808.9094.68529.stgit@gandelf.nowhere.earth","subject":"[PATCH 05/10] Copy parentbranch setting on 'stg branch --clone'.","fromName":"Yann Dirson","fromEmail":"ydirson@altern.org","sentAt":"2007-03-15T00:26:55Z","receivedAt":"2007-03-15T00:26:55Z","isPatch":true,"sender":{"key":"ydirson@altern.org","avatar":"https://avatars.githubusercontent.com/u/1190950?v=4"},"body":"\n\n\nSigned-off-by: Yann Dirson <ydirson@altern.org>\n---\n\n stgit/stack.py |    6 +++++-\n 1 files changed, 5 insertions(+), 1 deletions(-)\n\ndiff --git a/stgit/stack.py b/stgit/stack.py\nindex ec75507..d1b04ca 100644\n--- a/stgit/stack.py\n+++ b/stgit/stack.py\n@@ -639,7 +639,7 @@ class Series(StgitObject):\n         # fast forward the cloned series to self's top\n         new_series.forward_patches(applied)\n \n-        # Clone remote and merge settings\n+        # Clone parent informations\n         value = config.get('branch.%s.remote' % self.__name)\n         if value:\n             config.set('branch.%s.remote' % target_series, value)\n@@ -648,6 +648,10 @@ class Series(StgitObject):\n         if value:\n             config.set('branch.%s.merge' % target_series, value)\n \n+        value = config.get('branch.%s.stgit.parentbranch' % self.__name)\n+        if value:\n+            config.set('branch.%s.stgit.parentbranch' % target_series, value)\n+\n     def delete(self, force = False):\n         \"\"\"Deletes an stgit series\n         \"\"\"\n"},{"id":"37140","messageId":"20070315002700.9094.84569.stgit@gandelf.nowhere.earth","threadId":"7253","inReplyTo":"20070315001808.9094.68529.stgit@gandelf.nowhere.earth","subject":"[PATCH 06/10] Remove debugging output from contrib/stg-sink","fromName":"Yann Dirson","fromEmail":"ydirson@altern.org","sentAt":"2007-03-15T00:27:00Z","receivedAt":"2007-03-15T00:27:00Z","isPatch":true,"sender":{"key":"ydirson@altern.org","avatar":"https://avatars.githubusercontent.com/u/1190950?v=4"},"body":"\n\n\nSigned-off-by: Yann Dirson <ydirson@altern.org>\n---\n\n contrib/stg-sink |    2 +-\n 1 files changed, 1 insertions(+), 1 deletions(-)\n\ndiff --git a/contrib/stg-sink b/contrib/stg-sink\nindex e63eb93..cb6e25d 100755\n--- a/contrib/stg-sink\n+++ b/contrib/stg-sink\n@@ -3,7 +3,7 @@ use strict;\n use warnings;\n \n sub _run {\n-  print(' >> ', @_, \"\\n\");# and 0;\n+  #print(' >> ', @_, \"\\n\");# and 0;\n   system(@_);\n }\n \n"},{"id":"37142","messageId":"20070315002705.9094.21878.stgit@gandelf.nowhere.earth","threadId":"7253","inReplyTo":"20070315001808.9094.68529.stgit@gandelf.nowhere.earth","subject":"[PATCH 07/10] Stop recording branch.*.remote to '.' for local parents.","fromName":"Yann Dirson","fromEmail":"ydirson@altern.org","sentAt":"2007-03-15T00:27:05Z","receivedAt":"2007-03-15T00:27:05Z","isPatch":true,"sender":{"key":"ydirson@altern.org","avatar":"https://avatars.githubusercontent.com/u/1190950?v=4"},"body":"\nWe should be using the remote name of the remote branch in\nbranch.*.merge, instead of the local one as we currently do (I'll\nensure this in a later patch).\n\nAs a consequence, setting \"remote\" to '.' and \"merge\" to the name of a\n*local* parent would become inconsistent with the remote case.  Anyway\nthe local case should make use of pull-policy=rebase instead, and this\nchange revealed that we were fetching useless information in the local\ncase (no need for a remote).\n\nSigned-off-by: Yann Dirson <ydirson@altern.org>\n---\n\n stgit/commands/pull.py |   24 +++++++++++++++++-------\n stgit/stack.py         |    4 +---\n 2 files changed, 18 insertions(+), 10 deletions(-)\n\ndiff --git a/stgit/commands/pull.py b/stgit/commands/pull.py\nindex 7b3c90c..f551b98 100644\n--- a/stgit/commands/pull.py\n+++ b/stgit/commands/pull.py\n@@ -50,13 +50,25 @@ options = [make_option('-n', '--nopush',\n def func(parser, options, args):\n     \"\"\"Pull the changes from a remote repository\n     \"\"\"\n-    if len(args) > 1:\n-        parser.error('incorrect number of arguments')\n+    policy = config.get('branch.%s.stgit.pull-policy' % crt_series.get_branch()) or \\\n+             config.get('stgit.pull-policy')\n+\n+    if policy == 'rebase':\n+        # parent is local\n+        if len(args) == 1:\n+            parser.error('specifying a repository is meaningless for policy=\"%s\"' % policy)\n+        if len(args) > 0:\n+            parser.error('incorrect number of arguments')\n \n-    if len(args) >= 1:\n-        repository = args[0]\n     else:\n-        repository = crt_series.get_parent_remote()\n+        # parent is remote\n+        if len(args) > 1:\n+            parser.error('incorrect number of arguments')\n+\n+        if len(args) >= 1:\n+            repository = args[0]\n+        else:\n+            repository = crt_series.get_parent_remote()\n \n     if crt_series.get_protected():\n         raise CmdException, 'This branch is protected. Pulls are not permitted'\n@@ -65,8 +77,6 @@ def func(parser, options, args):\n     check_conflicts()\n     check_head_top_equal()\n \n-    policy = config.get('branch.%s.stgit.pull-policy' % crt_series.get_branch()) or \\\n-             config.get('stgit.pull-policy')\n     if policy == 'pull':\n         must_rebase = 0\n     elif policy == 'fetch-rebase':\ndiff --git a/stgit/stack.py b/stgit/stack.py\nindex d1b04ca..c3dab68 100644\n--- a/stgit/stack.py\n+++ b/stgit/stack.py\n@@ -450,10 +450,8 @@ class Series(StgitObject):\n         config.set('branch.%s.stgit.parentbranch' % self.__name, name)\n \n     def set_parent(self, remote, localbranch):\n-        # policy: record local branches as remote='.'\n-        recordremote = remote or '.'\n         if localbranch:\n-            self.__set_parent_remote(recordremote)\n+            self.__set_parent_remote(remote)\n             self.__set_parent_branch(localbranch)\n         # We'll enforce this later\n #         else:\n"},{"id":"37141","messageId":"20070315002710.9094.91958.stgit@gandelf.nowhere.earth","threadId":"7253","inReplyTo":"20070315001808.9094.68529.stgit@gandelf.nowhere.earth","subject":"[PATCH 08/10] Add a script to quickly run an interactive test session.","fromName":"Yann Dirson","fromEmail":"ydirson@altern.org","sentAt":"2007-03-15T00:27:10Z","receivedAt":"2007-03-15T00:27:10Z","isPatch":true,"sender":{"key":"ydirson@altern.org","avatar":"https://avatars.githubusercontent.com/u/1190950?v=4"},"body":"\nThis uses the capabilities of the test library to provide a throw-away\nplayground to test how the current stgit tree behaves.\n\nTo use it, run the following command:\n\t(cd t && ./interactive.sh)\n\nYou'll get a shell in a brand new git tree.  Exiting that shell will\nget rid of this temporary directory.\n\nSigned-off-by: Yann Dirson <ydirson@altern.org>\n---\n\n t/interactive.sh |   12 ++++++++++++\n 1 files changed, 12 insertions(+), 0 deletions(-)\n\ndiff --git a/t/interactive.sh b/t/interactive.sh\nnew file mode 100755\nindex 0000000..e4eaef9\n--- /dev/null\n+++ b/t/interactive.sh\n@@ -0,0 +1,12 @@\n+#!/bin/sh\n+#\n+# Copyright (c) 2007 Yann Dirson\n+#\n+\n+test_description='Get a test environment for interactive experimentation.'\n+\n+. ./test-lib.sh\n+\n+bash\n+\n+test_done\n"},{"id":"37143","messageId":"20070315002715.9094.93088.stgit@gandelf.nowhere.earth","threadId":"7253","inReplyTo":"20070315001808.9094.68529.stgit@gandelf.nowhere.earth","subject":"[PATCH 09/10] Add support for unsetting config vars.","fromName":"Yann Dirson","fromEmail":"ydirson@altern.org","sentAt":"2007-03-15T00:27:15Z","receivedAt":"2007-03-15T00:27:15Z","isPatch":true,"sender":{"key":"ydirson@altern.org","avatar":"https://avatars.githubusercontent.com/u/1190950?v=4"},"body":"\n\n\nSigned-off-by: Yann Dirson <ydirson@altern.org>\n---\n\n stgit/config.py |    3 +++\n 1 files changed, 3 insertions(+), 0 deletions(-)\n\ndiff --git a/stgit/config.py b/stgit/config.py\nindex b016fbd..79cd12f 100644\n--- a/stgit/config.py\n+++ b/stgit/config.py\n@@ -103,6 +103,9 @@ class GitConfig:\n     def set(self, name, value):\n         self.__run('git-repo-config', [name, value])\n \n+    def unset(self, name):\n+        self.__run('git-repo-config --unset', [name])\n+\n     def sections_matching(self, regexp):\n         \"\"\"Takes a regexp with a single group, matches it against all\n         config variables, and returns a list whose members are the\n"},{"id":"37144","messageId":"20070315002720.9094.44659.stgit@gandelf.nowhere.earth","threadId":"7253","inReplyTo":"20070315001808.9094.68529.stgit@gandelf.nowhere.earth","subject":"[PATCH 10/10] Cleanup parent information on stgit branch deletion.","fromName":"Yann Dirson","fromEmail":"ydirson@altern.org","sentAt":"2007-03-15T00:27:20Z","receivedAt":"2007-03-15T00:27:20Z","isPatch":true,"sender":{"key":"ydirson@altern.org","avatar":"https://avatars.githubusercontent.com/u/1190950?v=4"},"body":"\n\n\nSigned-off-by: Yann Dirson <ydirson@altern.org>\n---\n\n stgit/stack.py |    7 +++++++\n 1 files changed, 7 insertions(+), 0 deletions(-)\n\ndiff --git a/stgit/stack.py b/stgit/stack.py\nindex c3dab68..c6f338d 100644\n--- a/stgit/stack.py\n+++ b/stgit/stack.py\n@@ -700,6 +700,13 @@ class Series(StgitObject):\n             remove_file_and_dirs(\n                 os.path.join(self.__base_dir, 'refs', 'bases'), self.__name)\n \n+        # Cleanup parent informations\n+        # FIXME: should one day make use of git-config --section-remove,\n+        # scheduled for 1.5.1\n+        config.unset('branch.%s.remote' % self.__name)\n+        config.unset('branch.%s.merge' % self.__name)\n+        config.unset('branch.%s.stgit.parentbranch' % self.__name)\n+\n     def refresh_patch(self, files = None, message = None, edit = False,\n                       show_patch = False,\n                       cache_update = True,\n"}]}