From: "Karl Hasselström" <kha@treskal.com>
To: Catalin Marinas <catalin.marinas@gmail.com>
Cc: git@vger.kernel.org
Subject: [StGit PATCH] Let "stg assimilate" handle missing patches
Date: Thu, 27 Sep 2007 07:50:42 +0200 [thread overview]
Message-ID: <20070927055012.26131.33252.stgit@yoghurt> (raw)
In-Reply-To: <20070927054833.GA12207@diana.vm.bytemark.co.uk>
If a patch was not mentioned in the applied/unapplied files,
"assimilate" used to ignore it. Now it won't. The only information
loss ensuing from this sequence of commands
$ rm .git/patches/<branch>/{un,}applied
$ touch .git/patches/<branch>/{un,}applied
$ stg assimilate
is now the order of the unapplied patches.
Signed-off-by: Karl Hasselström <kha@treskal.com>
---
stgit/commands/assimilate.py | 32 ++++++++++++++++++++------------
1 files changed, 20 insertions(+), 12 deletions(-)
diff --git a/stgit/commands/assimilate.py b/stgit/commands/assimilate.py
index ab2264a..43672fd 100644
--- a/stgit/commands/assimilate.py
+++ b/stgit/commands/assimilate.py
@@ -90,7 +90,7 @@ def read_commit_dag(branch):
for line in Run('git-show-ref').output_lines():
id, ref = line.split()
m = re.match(r'^refs/patches/%s/(.+)$' % branch, ref)
- if m:
+ if m and not m.group(1).endswith('.log'):
c = commits[id]
c.patch = m.group(1)
patches.add(c)
@@ -173,17 +173,25 @@ def func(parser, options, args):
# Write the applied/unapplied files.
out.start('Checking patch appliedness')
+ unapplied = patches - set(applied)
applied_name_set = set(p.patch for p in applied)
- unapplied_names = []
- for name in orig_applied:
- if not name in applied_name_set:
- out.info('%s is now unapplied' % name)
- unapplied_names.append(name)
- for name in orig_unapplied:
- if name in applied_name_set:
- out.info('%s is now applied' % name)
- else:
- unapplied_names.append(name)
+ unapplied_name_set = set(p.patch for p in unapplied)
+ patches_name_set = set(p.patch for p in patches)
+ orig_patches = orig_applied + orig_unapplied
+ orig_applied_name_set = set(orig_applied)
+ orig_unapplied_name_set = set(orig_unapplied)
+ orig_patches_name_set = set(orig_patches)
+ for name in orig_patches_name_set - patches_name_set:
+ out.info('%s is gone' % name)
+ for name in applied_name_set - orig_applied_name_set:
+ out.info('%s is now applied' % name)
+ for name in unapplied_name_set - orig_unapplied_name_set:
+ out.info('%s is now unapplied' % name)
+ orig_order = dict(zip(orig_patches, xrange(len(orig_patches))))
+ def patchname_cmp(p1, p2):
+ i1 = orig_order.get(p1, len(orig_order))
+ i2 = orig_order.get(p2, len(orig_order))
+ return cmp((i1, p1), (i2, p2))
crt_series.set_applied(p.patch for p in applied)
- crt_series.set_unapplied(unapplied_names)
+ crt_series.set_unapplied(sorted(unapplied_name_set, cmp = patchname_cmp))
out.done()
prev parent reply other threads:[~2007-09-27 5:51 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-09-26 2:15 [StGit PATCH 0/2] "stg assimilate" on steroids Karl Hasselström
2007-09-26 2:15 ` [StGit PATCH 1/2] Teach "stg assimilate" to repair patch reachability Karl Hasselström
2007-09-26 2:15 ` [StGit PATCH 2/2] Test the new powers of "stg assimilate" Karl Hasselström
2007-09-27 5:48 ` [StGit PATCH 0/2] "stg assimilate" on steroids Karl Hasselström
2007-09-27 5:50 ` Karl Hasselström [this message]
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=20070927055012.26131.33252.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.