{"thread":{"id":"43191","subject":"[PATCH 0/4] Series short description","startedAt":"2006-11-23T23:16:27Z","lastAt":"2006-11-24T15:37:31Z","messageCount":6,"participants":["Yann Dirson","Catalin Marinas"],"isPatch":true,"patchVersion":1,"patchTotal":4},"messages":[{"id":"294006","messageId":"20061123230721.9769.38403.stgit@gandelf.nowhere.earth","threadId":"43191","inReplyTo":null,"subject":"[PATCH 0/4] Series short description","fromName":"Yann Dirson","fromEmail":"ydirson@altern.org","sentAt":"2006-11-23T23:16:27Z","receivedAt":"2006-11-23T23:16:27Z","isPatch":true,"sender":{"key":"ydirson@altern.org","avatar":"https://avatars.githubusercontent.com/u/1190950?v=4"},"body":"The following adds a --patch flag to \"stg refresh\".  I mainly needed it to\nedit the log message in patches down the stack, but with some work it could\nbe used to record changes in another file and come back.\n\nThat would require to pop patches with --keep, and if we ask to only record\na subset of the changes, we would need to implement \"push --keep\" first.\n\nThis patch is not perfect, since it reverses a list twice, but I did not\nfind an elegant way to make it better.  Python gurus, feel free to improve\nthis :)\n\nWhile I was at it, I noticed that \"stg goto\" need not revert the applied list\nif we're going to an unapplied patch (sorta compensate my extraneous revert above ;),\nand I noticed a DWIM behaviour on the (should-be)-erroneous \"refresh --ack --sign\".\n\n-- \nYann Dirson    <ydirson@altern.org> |\nDebian-related: <dirson@debian.org> |   Support Debian GNU/Linux:\n                                    |  Freedom, Power, Stability, Gratis\n"},{"id":"295617","messageId":"20061123231632.9769.72003.stgit@gandelf.nowhere.earth","threadId":"43191","inReplyTo":"20061123230721.9769.38403.stgit@gandelf.nowhere.earth","subject":"[PATCH 1/4] Make Series::patch_applied public.","fromName":"Yann Dirson","fromEmail":"ydirson@altern.org","sentAt":"2006-11-23T23:16:44Z","receivedAt":"2006-11-23T23:16: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 a477e7d..49cfebb 100644\n--- a/stgit/stack.py\n+++ b/stgit/stack.py\n@@ -417,7 +417,7 @@ class Series:\n     def __patch_is_current(self, patch):\n         return patch.get_name() == read_string(self.__current_file)\n \n-    def __patch_applied(self, name):\n+    def patch_applied(self, name):\n         \"\"\"Return true if the patch exists in the applied list\n         \"\"\"\n         return name in self.get_applied()\n@@ -430,7 +430,7 @@ class Series:\n     def patch_exists(self, name):\n         \"\"\"Return true if there is a patch with the given name, false\n         otherwise.\"\"\"\n-        return self.__patch_applied(name) or self.__patch_unapplied(name)\n+        return self.patch_applied(name) or self.__patch_unapplied(name)\n \n     def __begin_stack_check(self):\n         \"\"\"Save the current HEAD into .git/refs/heads/base if the stack\n@@ -713,7 +713,7 @@ class Series:\n                   before_existing = False, refresh = True):\n         \"\"\"Creates a new patch\n         \"\"\"\n-        if self.__patch_applied(name) or self.__patch_unapplied(name):\n+        if self.patch_applied(name) or self.__patch_unapplied(name):\n             raise StackException, 'Patch \"%s\" already exists' % name\n \n         if not message and can_edit:\n@@ -773,7 +773,7 @@ class Series:\n \n         if self.__patch_is_current(patch):\n             self.pop_patch(name)\n-        elif self.__patch_applied(name):\n+        elif self.patch_applied(name):\n             raise StackException, 'Cannot remove an applied patch, \"%s\", ' \\\n                   'which is not current' % name\n"},{"id":"296254","messageId":"20061123231649.9769.46624.stgit@gandelf.nowhere.earth","threadId":"43191","inReplyTo":"20061123230721.9769.38403.stgit@gandelf.nowhere.earth","subject":"[PATCH 2/4] Allows to refresh a non-top applied patch.","fromName":"Yann Dirson","fromEmail":"ydirson@altern.org","sentAt":"2006-11-23T23:16:53Z","receivedAt":"2006-11-23T23:16:53Z","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/commands/refresh.py |   25 ++++++++++++++++++++++---\n 1 files changed, 22 insertions(+), 3 deletions(-)\n\ndiff --git a/stgit/commands/refresh.py b/stgit/commands/refresh.py\nindex 610d18a..ea0fe6f 100644\n--- a/stgit/commands/refresh.py\n+++ b/stgit/commands/refresh.py\n@@ -66,6 +66,8 @@ options = [make_option('-f', '--force',\n            make_option('--commemail',\n                        help = 'use COMMEMAIL as the committer ' \\\n                        'e-mail'),\n+           make_option('-p', '--patch',\n+                       help = 'refresh named (applied) PATCH instead of the top one'),\n            make_option('--sign',\n                        help = 'add Signed-off-by line',\n                        action = 'store_true'),\n@@ -80,9 +82,15 @@ def func(parser, options, args):\n     if autoresolved != 'yes':\n         check_conflicts()\n \n-    patch = crt_series.get_current()\n-    if not patch:\n-        raise CmdException, 'No patches applied'\n+    if options.patch:\n+        patch = options.patch\n+        if not crt_series.patch_applied(patch):\n+            raise CmdException, 'Patches \"%s\" not applied' % patch\n+        origpatch = crt_series.get_current()\n+    else:\n+        patch = crt_series.get_current()\n+        if not patch:\n+            raise CmdException, 'No patches applied'\n \n     if not options.force:\n         check_head_top_equal()\n@@ -110,6 +118,13 @@ def func(parser, options, args):\n            or options.authname or options.authemail or options.authdate \\\n            or options.commname or options.commemail \\\n            or options.sign or options.ack:\n+\n+        if options.patch:\n+            applied = crt_series.get_applied()\n+            between = applied[applied.index(patch)+1:]\n+            between.reverse()\n+            pop_patches(between)\n+\n         print 'Refreshing patch \"%s\"...' % patch,\n         sys.stdout.flush()\n \n@@ -126,6 +141,10 @@ def func(parser, options, args):\n                                  committer_email = options.commemail,\n                                  backup = True, sign_str = sign_str)\n \n+        if options.patch:\n+            between.reverse()\n+            push_patches(between)\n+\n         print 'done'\n     else:\n"},{"id":"296913","messageId":"20061123231658.9769.81157.stgit@gandelf.nowhere.earth","threadId":"43191","inReplyTo":"20061123230721.9769.38403.stgit@gandelf.nowhere.earth","subject":"[PATCH 3/4] Optimize stg goto in the pop case.","fromName":"Yann Dirson","fromEmail":"ydirson@altern.org","sentAt":"2006-11-23T23:17:03Z","receivedAt":"2006-11-23T23:17:03Z","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/commands/goto.py |    2 +-\n 1 files changed, 1 insertions(+), 1 deletions(-)\n\ndiff --git a/stgit/commands/goto.py b/stgit/commands/goto.py\nindex 1b62d1c..e129b8d 100644\n--- a/stgit/commands/goto.py\n+++ b/stgit/commands/goto.py\n@@ -45,11 +45,11 @@ def func(parser, options, args):\n     check_head_top_equal()\n \n     applied = crt_series.get_applied()\n-    applied.reverse()\n     unapplied = crt_series.get_unapplied()\n     patch = args[0]\n \n     if patch in applied:\n+        applied.reverse()\n         patches = applied[:applied.index(patch)]\n         pop_patches(patches)\n"},{"id":"296906","messageId":"20061123231708.9769.53781.stgit@gandelf.nowhere.earth","threadId":"43191","inReplyTo":"20061123230721.9769.38403.stgit@gandelf.nowhere.earth","subject":"[PATCH 4/4] Bomb out when --ack and --sign are both passed to \"refresh\".","fromName":"Yann Dirson","fromEmail":"ydirson@altern.org","sentAt":"2006-11-23T23:17:12Z","receivedAt":"2006-11-23T23:17:12Z","isPatch":true,"sender":{"key":"ydirson@altern.org","avatar":"https://avatars.githubusercontent.com/u/1190950?v=4"},"body":"\nOld behaviour was silently ignoring --ack, which could be confusing.\n\nSigned-off-by: Yann Dirson <ydirson@altern.org>\n---\n\n stgit/commands/refresh.py |    2 ++\n 1 files changed, 2 insertions(+), 0 deletions(-)\n\ndiff --git a/stgit/commands/refresh.py b/stgit/commands/refresh.py\nindex ea0fe6f..aa5ff78 100644\n--- a/stgit/commands/refresh.py\n+++ b/stgit/commands/refresh.py\n@@ -107,6 +107,8 @@ def func(parser, options, args):\n \n     if options.sign:\n         sign_str = 'Signed-off-by'\n+        if options.ack:\n+            raise CmdException, '--ack and --sign were both specified'\n     elif options.ack:\n         sign_str = 'Acked-by'\n"},{"id":"295411","messageId":"b0943d9e0611240737h572bc5f8g3e9b34edf22fe1a5@mail.gmail.com","threadId":"43191","inReplyTo":"20061123230721.9769.38403.stgit@gandelf.nowhere.earth","subject":"Re: [PATCH 0/4] Series short description","fromName":"Catalin Marinas","fromEmail":"catalin.marinas@gmail.com","sentAt":"2006-11-24T15:37:31Z","receivedAt":"2006-11-24T15:37:31Z","isPatch":true,"sender":{"key":"catalin.marinas@gmail.com","avatar":null},"body":"On 23/11/06, Yann Dirson <ydirson@altern.org> wrote:\n> The following adds a --patch flag to \"stg refresh\".  I mainly needed it to\n> edit the log message in patches down the stack, but with some work it could\n> be used to record changes in another file and come back.\n>\n> That would require to pop patches with --keep,\n\npop_patches(keep=True) allows this (I already added it to your patch).\nThis option actually applies the reverse of the patch between the\ncurrent index and the bottom of the last patch to be popped. If it\nfails, it doesn't affect the current tree and reports an error.\n\n> and if we ask to only record\n> a subset of the changes, we would need to implement \"push --keep\" first.\n\nThe \"push --keep\" is a bit more complicated to implement since it\nwould usually have to generate commits (pop doesn't need to) since\nusually the base of the pushed patches might have changed (especially\nwith the refresh --patch). It is even more complicated if the changes\nyou want to preserve affect a file modified by the pushed patches.\n\nA solution I see is to generate a temporary diff, push the patches you\nwant and fold this temporary diff (the diff can be temporarily written\nto a local file so that you don't lose them in case of an error or\nCtrl-C). If the push fails (conflicts) or the diff no longer applies,\njust undo the push and re-apply the diff. There is no way to simply\ncheck whether all the patches apply (git-apply --check) since you\ncan't generate a single diff for all the pushed patches (which might\nnot be in the committed order).\n\n-- \n"}]}