Skip to contentSkip to conversation

Proposed patches

PATCH In review Catalin Marinas 2 participants 13 messages Jun 15, 2016

lore
Share & tools
lore
#0 lore raw

cover Proposed patches

A short series of proposed patches for merging into the StGIT master branch. The most important is the new patch identification scheme.

---

Catalin Marinas (4):
Remove the applied/unapplied commands
Convert git_id() to the new id format
Implement a new patch identification scheme and id command Allow e-mails to be sent with the Unix sendmail tool

 examples/gitconfig          |    1 
 stgit/commands/applied.py   |   51 --------------------
 stgit/commands/common.py    |  107 +++++++++++++++----------------------------
 stgit/commands/diff.py      |   21 ++++----
 stgit/commands/files.py     |   10 ++--
 stgit/commands/id.py        |   28 +++++------
 stgit/commands/mail.py      |   54 +++++++++++++++-------
 stgit/commands/pick.py      |   10 ++--
 stgit/commands/refresh.py   |    4 +-
 stgit/commands/series.py    |   17 +++++--
 stgit/commands/unapplied.py |   50 --------------------
 stgit/config.py             |    2 -
 stgit/lib/git.py            |    4 +-
 stgit/main.py               |    4 --
 t/t0001-subdir-branches.sh  |   24 ++++------
 t/t1002-branch-clone.sh     |    6 +-
 t/t1003-new.sh              |    4 +-
 t/t1200-push-modified.sh    |   14 +++---
 t/t1201-pull-trailing.sh    |    2 -
 t/t1203-pop.sh              |   12 ++---
 t/t1204-pop-keep.sh         |   12 ++---
 t/t1205-push-subdir.sh      |    4 +-
 t/t1301-repair.sh           |   12 ++---
 t/t1302-repair-interop.sh   |   20 ++++----
 t/t1500-float.sh            |   14 +++---
 t/t1600-delete-one.sh       |   28 ++++++-----
 t/t1601-delete-many.sh      |   24 +++++-----
 t/t2000-sync.sh             |   50 ++++++++++----------
 t/t2200-rebase.sh           |    6 +-
 t/t2500-clean.sh            |   12 ++---
 t/t2600-coalesce.sh         |   12 ++---
 t/t3000-dirty-merge.sh      |    8 ++-
 t/t4000-upgrade.sh          |    4 +-
 33 files changed, 256 insertions(+), 375 deletions(-)
 delete mode 100644 stgit/commands/applied.py
 delete mode 100644 stgit/commands/unapplied.py
Signature · 1 line
Catalin
#1 lore raw

PATCH 1/4 Allow e-mails to be sent with the Unix sendmail tool

If the stgit.smtpserver configuration option does not have a host:port format, it is assumed to be an external tool. For example, to use sendmail just set this variable to "/usr/sbin/sendmail -t -i" (see the examples/gitconfig file).

---

 examples/gitconfig     |    1 +
 stgit/commands/mail.py |   46 ++++++++++++++++++++++++++++++++++------------
 stgit/config.py        |    2 +-
 3 files changed, 36 insertions(+), 13 deletions(-)
examples/gitconfig +1 -0
index c16f786..28d94af 100644
@@ -19,6 +19,7 @@
 	#autoresolved = no
 
 	# SMTP server for sending patches
+	#smtpserver = /usr/sbin/sendmail -t -i
 	#smtpserver = localhost:25
 
 	# Set to 'yes' to use SMTP over TLS
stgit/commands/mail.py +34 -12

82 lines not on this page · raw message

stgit/config.py +1 -1
index 9bfdd52..9b26fa6 100644
@@ -29,7 +29,7 @@ class GitConfigException(StgException):
 class GitConfig:
     __defaults={
         'stgit.autoresolved':	'no',
-        'stgit.smtpserver':	'localhost:25',
+        'stgit.smtpserver':	'/usr/sbin/sendmail -t -i',
         'stgit.smtpdelay':	'5',
         'stgit.pullcmd':	'git pull',
         'stgit.fetchcmd':	'git fetch',
#2 lore raw

Re: [StGIT PATCH 1/4] Allow e-mails to be sent with the Unix sendmail tool

Quoted 4 lines · Catalin Marinas

If the stgit.smtpserver configuration option does not have a host:port format, it is assumed to be an external tool. For example, to use sendmail just set this variable to "/usr/sbin/sendmail -t -i" (see the examples/gitconfig file).

Some comments below, but it looks good.

stgit/commands/mail.py def __parse_addresses(msg): · line 195

Quoted 5 lines
stgit/commands/mail.py +5 -0
+def __send_message_sendmail(sendmail, msg):
+    """Send the message using the sendmail command.
+    """
+    cmd = sendmail.split()
+    Run(*cmd).raw_input(msg).discard_output()

You could've written this without the "cmd" variable, but I understand why you didn't. The * operator (or whatever it is) isn't pretty. I sort of regret not making Run take a list argument instead, frankly.

stgit/config.py class GitConfigException(StgException): · line 32

Quoted 5 lines

class GitConfig:

     __defaults={
         'stgit.autoresolved':	'no',
stgit/config.py +1 -1
-        'stgit.smtpserver':	'localhost:25',
+        'stgit.smtpserver':	'/usr/sbin/sendmail -t -i',

Hmm. I think it's actually more common to have a misconfigured (or insufficiently configured) sendmail program than a misconfigured mail daemon listening to port 25, so I'd argue that the default shouldn't be changed. But it's not that important.

Signature · 2 lines
Karl Hasselström, [email protected]
      www.treskal.com/kalle
#3 lore raw

Re: [StGIT PATCH 1/4] Allow e-mails to be sent with the Unix sendmail tool

2008/6/22 Karl Hasselström <[email protected]>:

Quoted 11 lines · Catalin Marinas

stgit/config.py class GitConfigException(StgException): · line 32

Quoted 5 lines

class GitConfig:

     __defaults={
         'stgit.autoresolved':        'no',
stgit/config.py +1 -1
-        'stgit.smtpserver':  'localhost:25',
+        'stgit.smtpserver':  '/usr/sbin/sendmail -t -i',

Hmm. I think it's actually more common to have a misconfigured (or insufficiently configured) sendmail program than a misconfigured mail daemon listening to port 25, so I'd argue that the default shouldn't be changed. But it's not that important.

OK, I'll leave the existing default (but I found in recent years that major Linux distributions come with pretty sane configuration).

Signature · 1 line
Catalin
#4 lore raw

PATCH 2/4 Implement a new patch identification scheme and id command

In reply to Catalin Marinas

The new scheme allows '[<branch>:]<patch>' and '[<branch>:]{base}' (the latter showing the base of a stack). The former format allows symbols like ^ and ^{...}.

---

 stgit/commands/common.py   |   32 ++++++++++++++++++++++++++++++++
 stgit/commands/id.py       |   28 ++++++++++++----------------
 stgit/lib/git.py           |    4 ++--
 t/t0001-subdir-branches.sh |   24 ++++++++++--------------
 t/t1200-push-modified.sh   |    2 +-
 t/t1201-pull-trailing.sh   |    2 +-
 t/t2200-rebase.sh          |    2 +-
 7 files changed, 59 insertions(+), 35 deletions(-)
stgit/commands/common.py +32 -0
index 029ec65..349389f 100644
@@ -28,6 +28,7 @@ from stgit.run import *
 from stgit import stack, git, basedir
 from stgit.config import config, file_extensions
 from stgit.lib import stack as libstack
+from stgit.lib import git as libgit
 
 # Command exception class
 class CmdException(StgException):
@@ -116,6 +117,37 @@ def git_id(crt_series, rev):
 
     raise CmdException, 'Unknown patch or revision: %s' % rev
 
+def git_commit(name, repository, branch = None):
+    """Return the a Commit object if 'name' is a patch name or Git commit.
+    The patch names allowed are in the form '<branch>:<patch>' and can be
+    followed by standard symbols used by git-rev-parse. If <patch> is '{base}',
+    it represents the bottom of the stack.
+    """
+    # Try a [branch:]patch name first
+    try:
+        branch, patch = name.split(':', 1)
+    except ValueError:
+        patch = name
+    if not branch:
+        branch = repository.current_branch_name
+
+    # The stack base
+    if patch == '{base}':
+        return repository.get_stack(branch).base
+
+    # Other combination of branch and patch
+    try:
+        return repository.rev_parse('patches/%s/%s' % (branch, patch),
+                                    discard_stderr = True)
+    except libgit.RepositoryException:
+        pass
+
+    # Try a Git commit
+    try:
+        return repository.rev_parse(name, discard_stderr = True)
+    except libgit.RepositoryException:
+        raise CmdException('%s: Unknown patch or revision name' % name)
+
 def check_local_changes():
     if git.local_changes():
         raise CmdException('local changes in the tree. Use "refresh" or'
stgit/commands/id.py +12 -16
index 94b0229..3819acc 100644
@@ -15,28 +15,24 @@ along with this program; if not, write to the Free Software
 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
 """
 
-import sys, os
 from optparse import OptionParser, make_option
 
-from stgit.commands.common import *
-from stgit.utils import *
-from stgit.out import *
-from stgit import stack, git
-
+from stgit.out import out
+from stgit.commands import common
+from stgit.lib import stack
 
 help = 'print the GIT hash value of a StGIT reference'
 usage = """%prog [options] [id]
 
-Print the hash value of a GIT id (defaulting to HEAD). In addition to
-the standard GIT id's like heads and tags, this command also accepts
-'base[@<branch>]' and '[<patch>[@<branch>]][//[bottom | top]]'. If no
-'top' or 'bottom' are passed and <patch> is a valid patch name, 'top'
-will be used by default."""
-
-directory = DirectoryHasRepository()
-options = [make_option('-b', '--branch',
-                       help = 'use BRANCH instead of the default one')]
+Print the SHA1 value of a Git id (defaulting to HEAD). In addition to
+the standard Git id's like heads and tags, this command also accepts
+'[<branch>:]<patch>' and '[<branch>:]{base}' showing the id of a patch
+or the base of the stack. If no branch is specified, it defaults to the
+current one. The bottom of a patch is accessible with the
+'[<branch>:]<patch>^' format."""
 
+directory = common.DirectoryHasRepositoryLib()
+options = []
 
 def func(parser, options, args):
     """Show the applied patches
@@ -48,4 +44,4 @@ def func(parser, options, args):
     else:
         parser.error('incorrect number of arguments')
 
-    out.stdout(git_id(crt_series, id_str))
+    out.stdout(common.git_commit(id_str, directory.repository).sha1)
stgit/lib/git.py +2 -2
index 6ccdfa7..4746da3 100644
@@ -422,11 +422,11 @@ class Repository(RunWithEnv):
     refs = property(lambda self: self.__refs)
     def cat_object(self, sha1):
         return self.run(['git', 'cat-file', '-p', sha1]).raw_output()
-    def rev_parse(self, rev):
+    def rev_parse(self, rev, discard_stderr = False):
         try:
             return self.get_commit(self.run(
                     ['git', 'rev-parse', '%s^{commit}' % rev]
-                    ).output_one_line())
+                    ).discard_stderr(discard_stderr).output_one_line())
         except run.RunException:
             raise RepositoryException('%s: No such revision' % rev)
     def get_tree(self, sha1):
t/t0001-subdir-branches.sh +10 -14
index 0eed3a4..4df0481 100755
@@ -18,25 +18,21 @@ test_expect_success 'Create a patch' \
    stg new foo -m "Add foo.txt" &&
    stg refresh'
 
-test_expect_success 'Old and new id with non-slashy branch' \
-  'stg id foo &&
-   stg id foo// &&
-   stg id foo/ &&
-   stg id foo//top &&
-   stg id foo/top &&
-   stg id foo@master &&
-   stg id foo@master//top &&
-   stg id foo@master/top'
+test_expect_success 'Try id with non-slashy branch' \
+  'stg id &&
+   stg id foo &&
+   stg id foo^ &&
+   stg id master:foo &&
+   stg id master:foo^'
 
 test_expect_success 'Clone branch to slashier name' \
   'stg branch --clone x/y/z'
 
-test_expect_success 'Try new form of id with slashy branch' \
+test_expect_success 'Try new id with slashy branch' \
   'stg id foo &&
-   stg id foo// &&
-   stg id foo//top &&
-   stg id foo@x/y/z &&
-   stg id foo@x/y/z//top'
+   stg id foo^ &&
+   stg id x/y/z:foo &&
+   stg id x/y/z:foo^'
 
 test_expect_success 'Try old id with slashy branch' '
    ! stg id foo/ &&
t/t1200-push-modified.sh +1 -1
index ba4f70c..e3c6425 100755
@@ -36,7 +36,7 @@ test_expect_success \
     (
         cd foo &&
         GIT_DIR=../bar/.git git-format-patch --stdout \
-          $(cd ../bar && stg id base@master)..HEAD | git-am -3 -k
+          $(cd ../bar && stg id master:{base})..HEAD | git-am -3 -k
     )
 '
 
t/t1201-pull-trailing.sh +1 -1
index 9d70fe0..8a74873 100755
@@ -30,7 +30,7 @@ test_expect_success \
     'Port those patches to orig tree' \
     '(cd foo &&
       GIT_DIR=../bar/.git git-format-patch --stdout \
-          $(cd ../bar && stg id base@master)..HEAD |
+          $(cd ../bar && stg id master:{base})..HEAD |
       git-am -3 -k
      )
     '
t/t2200-rebase.sh +1 -1
index ec2a104..cd43c41 100755
@@ -27,7 +27,7 @@ test_expect_success \
 	'Rebase to previous commit' \
 	'
 	stg rebase master~1 &&
-	test `stg id base@stack` = `git rev-parse master~1` &&
+	test `stg id stack:{base}` = `git rev-parse master~1` &&
 	test `stg applied | wc -l` = 1
 	'
 
#5 lore raw

Re: [StGIT PATCH 2/4] Implement a new patch identification scheme and id command

Quoted 3 lines · Catalin Marinas

The new scheme allows '[<branch>:]<patch>' and '[<branch>:]{base}' (the latter showing the base of a stack). The former format allows symbols like ^ and ^{...}.

Hmm. Why only the former? Supporting it for the latter should be easy. (Though it would take some extra work, I guess.)

Other than that, it looks good to me.

stgit/commands/common.py def git_id(crt_series, rev): · line 123

Quoted 4 lines
stgit/commands/common.py +4 -0
+def git_commit(name, repository, branch = None):
+    """Return the a Commit object if 'name' is a patch name or Git commit.
+    The patch names allowed are in the form '<branch>:<patch>' and can be
+    followed by standard symbols used by git-rev-parse. If <patch> is '{base}',

Long line.

stgit/commands/common.py def git_id(crt_series, rev): · line 136

Quoted 3 lines
stgit/commands/common.py +3 -0
+    # The stack base
+    if patch == '{base}':
+        return repository.get_stack(branch).base

Should be a simple matter of

if patch.startswith('{base}'):
foo = repository.get_stack(branch).base + drop_prefix(patch, '{base}') return repository.rev_parse(foo)

or something.

Signature · 2 lines
Karl Hasselström, [email protected]
      www.treskal.com/kalle
#6 lore raw

PATCH 3/4 Convert git_id() to the new id format

In reply to Catalin Marinas

The patch rewrites git_id() to use the new id format and coverts the commands using this function. The git_id() will be removed once all the commands are converted to the new infrastructure where git_commit() will be used instead.

---

 stgit/commands/common.py  |   97 ++++++++-------------------------------------
 stgit/commands/diff.py    |   21 ++++------
 stgit/commands/files.py   |   10 ++---
 stgit/commands/mail.py    |    8 ++--
 stgit/commands/pick.py    |   10 ++---
 stgit/commands/refresh.py |    4 +-
 stgit/commands/series.py  |    4 +-
 t/t2000-sync.sh           |    2 -
 8 files changed, 43 insertions(+), 113 deletions(-)
stgit/commands/common.py +17 -80
index 349389f..3e1d2d0 100644
@@ -35,101 +35,38 @@ class CmdException(StgException):
     pass
 
 # Utility functions
-class RevParseException(StgException):
-    """Revision spec parse error."""
-    pass
-
 def parse_rev(rev):
-    """Parse a revision specification into its
-    patchname@branchname//patch_id parts. If no branch name has a slash
-    in it, also accept / instead of //."""
-    if '/' in ''.join(git.get_heads()):
-        # We have branch names with / in them.
-        branch_chars = r'[^@]'
-        patch_id_mark = r'//'
-    else:
-        # No / in branch names.
-        branch_chars = r'[^@/]'
-        patch_id_mark = r'(/|//)'
-    patch_re = r'(?P<patch>[^@/]+)'
-    branch_re = r'@(?P<branch>%s+)' % branch_chars
-    patch_id_re = r'%s(?P<patch_id>[a-z.]*)' % patch_id_mark
-
-    # Try //patch_id.
-    m = re.match(r'^%s$' % patch_id_re, rev)
-    if m:
-        return None, None, m.group('patch_id')
-
-    # Try path[@branch]//patch_id.
-    m = re.match(r'^%s(%s)?%s$' % (patch_re, branch_re, patch_id_re), rev)
-    if m:
-        return m.group('patch'), m.group('branch'), m.group('patch_id')
-
-    # Try patch[@branch].
-    m = re.match(r'^%s(%s)?$' % (patch_re, branch_re), rev)
-    if m:
-        return m.group('patch'), m.group('branch'), None
-
-    # No, we can't parse that.
-    raise RevParseException
+    """Parse a revision specification into its branch:patch parts.
+    """
+    try:
+        branch, patch = rev.split(':', 1)
+    except ValueError:
+        branch = None
+        patch = rev
+
+    return (branch, patch)
 
 def git_id(crt_series, rev):
     """Return the GIT id
     """
+    # TODO: remove this function once all the occurrences were converted
+    # to git_commit()
     if not rev:
+        # backwards compatibility
         return None
+    repository = libstack.Repository.default()
+    return git_commit(rev, repository, crt_series.get_name()).sha1
 
-    # try a GIT revision first
-    try:
-        return git.rev_parse(rev + '^{commit}')
-    except git.GitException:
-        pass
-
-    # try an StGIT patch name
-    try:
-        patch, branch, patch_id = parse_rev(rev)
-        if branch == None:
-            series = crt_series
-        else:
-            series = stack.Series(branch)
-        if patch == None:
-            patch = series.get_current()
-            if not patch:
-                raise CmdException, 'No patches applied'
-        if patch in series.get_applied() or patch in series.get_unapplied() or \
-               patch in series.get_hidden():
-            if patch_id in ['top', '', None]:
-                return series.get_patch(patch).get_top()
-            elif patch_id == 'bottom':
-                return series.get_patch(patch).get_bottom()
-            elif patch_id == 'top.old':
-                return series.get_patch(patch).get_old_top()
-            elif patch_id == 'bottom.old':
-                return series.get_patch(patch).get_old_bottom()
-            elif patch_id == 'log':
-                return series.get_patch(patch).get_log()
-        if patch == 'base' and patch_id == None:
-            return series.get_base()
-    except RevParseException:
-        pass
-    except stack.StackException:
-        pass
-
-    raise CmdException, 'Unknown patch or revision: %s' % rev
-
-def git_commit(name, repository, branch = None):
+def git_commit(name, repository, branch_name = None):
     """Return the a Commit object if 'name' is a patch name or Git commit.
     The patch names allowed are in the form '<branch>:<patch>' and can be
     followed by standard symbols used by git-rev-parse. If <patch> is '{base}',
     it represents the bottom of the stack.
     """
     # Try a [branch:]patch name first
-    try:
-        branch, patch = name.split(':', 1)
-    except ValueError:
-        patch = name
+    branch, patch = parse_rev(name)
     if not branch:
-        branch = repository.current_branch_name
+        branch = branch_name or repository.current_branch_name
 
     # The stack base
     if patch == '{base}':
stgit/commands/diff.py +9 -12
index fd6be34..4ae9b49 100644
@@ -30,17 +30,14 @@ help = 'show the tree diff'
 usage = """%prog [options] [<files or dirs>]
 
 Show the diff (default) or diffstat between the current working copy
-or a tree-ish object and another tree-ish object. File names can also
-be given to restrict the diff output. The tree-ish object can be a
-standard git commit, tag or tree. In addition to these, the command
-also supports 'base', representing the bottom of the current stack,
-and '[patch][//[bottom | top]]' for the patch boundaries (defaulting to
-the current one):
+or a tree-ish object and another tree-ish object (defaulting to HEAD).
+File names can also be given to restrict the diff output. The
+tree-ish object can be an StGIT patch, a standard git commit, tag or
+tree. In addition to these, the command also supports '{base}',
+representing the bottom of the current stack.
 
-rev = '([patch][//[bottom | top]]) | <tree-ish> | base'
-
-If neither bottom nor top are given but a '//' is present, the command
-shows the specified patch (defaulting to the current one)."""
+rev = '([branch:]patch) | <tree-ish> | base'
+"""
 
 directory = DirectoryHasRepository()
 options = [make_option('-r', '--range',
@@ -67,8 +64,8 @@ def func(parser, options, args):
                 rev = strip_suffix('/', rev)
                 if rev.endswith('/'):
                     rev = strip_suffix('/', rev)
-                rev1 = rev + '//bottom'
-                rev2 = rev + '//top'
+                rev1 = rev + 'HEAD^'
+                rev2 = rev + 'HEAD'
             else:
                 rev1 = rev_list[0]
                 rev2 = None
stgit/commands/files.py +4 -6
index b43b12f..d240872 100644
@@ -26,7 +26,7 @@ from stgit import stack, git
 
 
 help = 'show the files modified by a patch (or the current patch)'
-usage = """%prog [options] [<patch>]
+usage = """%prog [options] [[<branch>:]<patch>]
 
 List the files modified by the given patch (defaulting to the current
 one). Passing the '--stat' option shows the diff statistics for the
@@ -38,8 +38,6 @@ directory = DirectoryHasRepository()
 options = [make_option('-s', '--stat',
                        help = 'show the diff stat',
                        action = 'store_true'),
-           make_option('-b', '--branch',
-                       help = 'use BRANCH instead of the default one'),
            make_option('--bare',
                        help = 'bare file names (useful for scripting)',
                        action = 'store_true')
@@ -50,14 +48,14 @@ def func(parser, options, args):
     """Show the files modified by a patch (or the current patch)
     """
     if len(args) == 0:
-        patch = ''
+        patch = 'HEAD'
     elif len(args) == 1:
         patch = args[0]
     else:
         parser.error('incorrect number of arguments')
 
-    rev1 = git_id(crt_series, '%s//bottom' % patch)
-    rev2 = git_id(crt_series, '%s//top' % patch)
+    rev1 = git_id(crt_series, '%s^' % patch)
+    rev2 = git_id(crt_series, '%s' % patch)
 
     if options.stat:
         out.stdout_raw(git.diffstat(git.diff(rev1 = rev1, rev2 = rev2)) + '\n')
stgit/commands/mail.py +4 -4
index c87d67e..e04dc2f 100644
@@ -383,8 +383,8 @@ def __build_cover(tmpl, patches, msg_id, options):
                  'shortlog':     stack.shortlog(crt_series.get_patch(p)
                                                 for p in patches),
                  'diffstat':     git.diffstat(git.diff(
-                     rev1 = git_id(crt_series, '%s//bottom' % patches[0]),
-                     rev2 = git_id(crt_series, '%s//top' % patches[-1])))}
+                     rev1 = git_id(crt_series, '%s^' % patches[0]),
+                     rev2 = git_id(crt_series, '%s' % patches[-1])))}
 
     try:
         msg_string = tmpl % tmpl_dict
@@ -460,8 +460,8 @@ def __build_message(tmpl, patch, patch_nr, total_nr, msg_id, ref_id, options):
     else:
         number_str = ''
 
-    diff = git.diff(rev1 = git_id(crt_series, '%s//bottom' % patch),
-                    rev2 = git_id(crt_series, '%s//top' % patch),
+    diff = git.diff(rev1 = git_id(crt_series, '%s^' % patch),
+                    rev2 = git_id(crt_series, '%s' % patch),
                     diff_flags = options.diff_flags)
     tmpl_dict = {'patch':        patch,
                  'sender':       sender,
stgit/commands/pick.py +4 -6
index 1f7c84b..2a670e8 100644
@@ -87,8 +87,8 @@ def __pick_commit(commit_id, patchname, options):
 
         out.done()
     elif options.update:
-        rev1 = git_id(crt_series, '//bottom')
-        rev2 = git_id(crt_series, '//top')
+        rev1 = git_id(crt_series, 'HEAD^')
+        rev2 = git_id(crt_series, 'HEAD')
         files = git.barefiles(rev1, rev2).split('\n')
 
         out.start('Updating with commit %s' % commit_id)
@@ -115,10 +115,8 @@ def __pick_commit(commit_id, patchname, options):
         patchname = newpatch.get_name()
 
         # find a patchlog to fork from
-        (refpatchname, refbranchname, refpatchid) = parse_rev(patchname)
-        if refpatchname and not refpatchid and \
-               (not refpatchid or refpatchid == 'top'):
-            # FIXME: should also support picking //top.old
+        refbranchname, refpatchname = parse_rev(patchname)
+        if refpatchname:
             if refbranchname:
                 # assume the refseries is OK, since we already resolved
                 # commit_str to a git_id
stgit/commands/refresh.py +2 -2
index 4695c62..73e4ee0 100644
@@ -103,8 +103,8 @@ def func(parser, options, args):
             between = applied[:applied.index(patch):-1]
             pop_patches(crt_series, between, keep = True)
         elif options.update:
-            rev1 = git_id(crt_series, '//bottom')
-            rev2 = git_id(crt_series, '//top')
+            rev1 = git_id(crt_series, 'HEAD^')
+            rev2 = git_id(crt_series, 'HEAD')
             patch_files = git.barefiles(rev1, rev2).split('\n')
             files = [f for f in files if f in patch_files]
             if not files:
stgit/commands/series.py +2 -2
index 04183bd..c11c74f 100644
@@ -88,7 +88,7 @@ def __print_patch(stack, patch, branch_str, prefix, empty_prefix, length, option
     elif options.empty and stack.patches.get(patch).is_empty():
         prefix = empty_prefix
 
-    patch_str = patch + branch_str
+    patch_str = branch_str + patch
 
     if options.description or options.author:
         patch_str = patch_str.ljust(length)
@@ -164,7 +164,7 @@ def func(parser, options, args):
         return
 
     if options.showbranch:
-        branch_str = '@' + stack.name
+        branch_str = stack.name + ':'
     else:
         branch_str = ''
 
t/t2000-sync.sh +1 -1
index e489603..4a00c56 100755
@@ -37,7 +37,7 @@ test_expect_success \
 test_expect_success \
     'Create a branch with empty patches' \
     '
-    stg branch -c foo base &&
+    stg branch -c foo {base} &&
     stg new p1 -m p1 &&
     stg new p2 -m p2 &&
     stg new p3 -m p3 &&
#7 lore raw

Re: [StGIT PATCH 3/4] Convert git_id() to the new id format

Quoted 4 lines · Catalin Marinas

The patch rewrites git_id() to use the new id format and coverts the commands using this function. The git_id() will be removed once all the commands are converted to the new infrastructure where git_commit() will be used instead.

Looks good. And the code volume reduction is significant.

Quoted 3 lines

if not rev:
+ # backwards compatibility
return None

Could you expand this comment a bit? It's not enough of a clue for me. :-/

stgit/commands/common.py class CmdException(StgException): · line 60

Quoted 2 lines
stgit/commands/common.py +1 -1
-def git_commit(name, repository, branch = None):
+def git_commit(name, repository, branch_name = None):

Very nice parameter rename here, now that we have Branch objects (and use a crappy language with no type system).

stgit/commands/diff.py help = 'show the tree diff' · line 39

Quoted 5 lines
stgit/commands/diff.py +1 -4
-rev = '([patch][//[bottom | top]]) | <tree-ish> | base'
-
-If neither bottom nor top are given but a '//' is present, the command
-shows the specified patch (defaulting to the current one)."""
+rev = '([branch:]patch) | <tree-ish> | base'

You can remove the parentheses now; they were only needed because they used to enclose a complicated expression. Besides, shouldn't it be [branch:]{base} instead of base? So something like

rev = [<branch>:]<patch> | [<branch>:]{base} | <tree-ish>

stgit/commands/files.py from stgit import stack, git · line 29

Quoted 3 lines

help = 'show the files modified by a patch (or the current patch)'

stgit/commands/files.py +1 -1
-usage = """%prog [options] [<patch>]
+usage = """%prog [options] [[<branch>:]<patch>]

Unrelated to this patch: I realized last week that it's silly for stg files to not accept a patch range.

stgit/commands/files.py def func(parser, options, args): · line 51

Quoted 3 lines
     if len(args) == 0:
stgit/commands/files.py +1 -1
-        patch = ''
+        patch = 'HEAD'

Ah, so this is the backwards compatibility thing -- we used to pass the empty string when we meant HEAD.

stgit/commands/pick.py def __pick_commit(commit_id, patchname, options): · line 119

Quoted 6 lines
stgit/commands/pick.py +2 -4
-        (refpatchname, refbranchname, refpatchid) = parse_rev(patchname)
-        if refpatchname and not refpatchid and \
-               (not refpatchid or refpatchid == 'top'):
-            # FIXME: should also support picking //top.old
+        refbranchname, refpatchname = parse_rev(patchname)
+        if refpatchname:

The corresponding TODO comment now would be that pick should be able to pick patches from the past, from the stack log.

Signature · 2 lines
Karl Hasselström, [email protected]
      www.treskal.com/kalle
#8 lore raw

Re: [StGIT PATCH 3/4] Convert git_id() to the new id format

2008/6/22 Karl Hasselström <[email protected]>:

Quoted 6 lines · Catalin Marinas
Quoted 5 lines

The patch rewrites git_id() to use the new id format and coverts the commands using this function. The git_id() will be removed once all the commands are converted to the new infrastructure where git_commit() will be used instead.

[...[

Quoted 6 lines
Quoted 3 lines

if not rev:
+ # backwards compatibility
return None

Could you expand this comment a bit? It's not enough of a clue for me. :-/

I removed it, the diff command used to pass None as rev2 if the user only passed one boundary of the range. I fixed diff and removed the above.

Quoted 5 lines

stgit/commands/common.py class CmdException(StgException): · line 60

Quoted 2 lines
stgit/commands/common.py +1 -1
-def git_commit(name, repository, branch = None):
+def git_commit(name, repository, branch_name = None):

Very nice parameter rename here, now that we have Branch objects (and use a crappy language with no type system).

It has a type system but no compile-time checking (I'm more in favour of static typing but no time to rewrite stgit :-)).

Quoted 9 lines

stgit/commands/pick.py def __pick_commit(commit_id, patchname, options): · line 119

Quoted 6 lines
stgit/commands/pick.py +2 -4
-        (refpatchname, refbranchname, refpatchid) = parse_rev(patchname)
-        if refpatchname and not refpatchid and \
-               (not refpatchid or refpatchid == 'top'):
-            # FIXME: should also support picking //top.old
+        refbranchname, refpatchname = parse_rev(patchname)
+        if refpatchname:

The corresponding TODO comment now would be that pick should be able to pick patches from the past, from the stack log.

How would the syntax look like?

Signature · 1 line
Catalin
#9 lore raw

Re: [StGIT PATCH 3/4] Convert git_id() to the new id format

Quoted 6 lines · Catalin Marinas

2008/6/22 Karl Hasselström <[email protected]>:

Quoted 2 lines

Very nice parameter rename here, now that we have Branch objects (and use a crappy language with no type system).

It has a type system but no compile-time checking

Yeah, that's what I meant.

Quoted 2 lines

(I'm more in favour of static typing but no time to rewrite stgit :-)).

Me too.

Quoted 4 lines
Quoted 2 lines

The corresponding TODO comment now would be that pick should be able to pick patches from the past, from the stack log.

How would the syntax look like?

We'd want to support <committish>:patch, for any committish that's a stack log (either simplified or full). Not sure if we'd want a more pretty-looking format as well.

Signature · 2 lines
Karl Hasselström, [email protected]
      www.treskal.com/kalle
#10 lore raw

PATCH 4/4 Remove the applied/unapplied commands

In reply to Catalin Marinas

This patch moves the applied/unapplied functionality to the 'series' command via the corresponding options.

---

 stgit/commands/applied.py   |   51 -------------------------------------------
 stgit/commands/series.py    |   13 +++++++++--
 stgit/commands/unapplied.py |   50 ------------------------------------------
 stgit/main.py               |    4 ---
 t/t1002-branch-clone.sh     |    6 +++--
 t/t1003-new.sh              |    4 ++-
 t/t1200-push-modified.sh    |   12 +++++-----
 t/t1203-pop.sh              |   12 +++++-----
 t/t1204-pop-keep.sh         |   12 +++++-----
 t/t1205-push-subdir.sh      |    4 ++-
 t/t1301-repair.sh           |   12 +++++-----
 t/t1302-repair-interop.sh   |   20 ++++++++---------
 t/t1500-float.sh            |   14 ++++++------
 t/t1600-delete-one.sh       |   28 ++++++++++++------------
 t/t1601-delete-many.sh      |   24 ++++++++++----------
 t/t2000-sync.sh             |   48 ++++++++++++++++++++--------------------
 t/t2200-rebase.sh           |    4 ++-
 t/t2500-clean.sh            |   12 +++++-----
 t/t2600-coalesce.sh         |   12 +++++-----
 t/t3000-dirty-merge.sh      |    8 +++----
 t/t4000-upgrade.sh          |    4 ++-
 21 files changed, 129 insertions(+), 225 deletions(-)
 delete mode 100644 stgit/commands/applied.py
 delete mode 100644 stgit/commands/unapplied.py
stgit/commands/applied.py deleted +0 -51
deleted file mode 100644
index e57c796..0000000
@@ -1,51 +0,0 @@
-
-__copyright__ = """
-Copyright (C) 2005, Catalin Marinas <[email protected]>
-
-This program is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License version 2 as
-published by the Free Software Foundation.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program; if not, write to the Free Software
-Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-"""
-
-from optparse import make_option
-from stgit.out import *
-from stgit.commands import common
-
-
-help = 'print the applied patches'
-usage = """%prog [options]
-
-List the patches from the series which have already been pushed onto
-the stack. They are listed in the order in which they were pushed, the
-last one being the current (topmost) patch."""
-
-directory = common.DirectoryHasRepositoryLib()
-options = [make_option('-b', '--branch',
-                       help = 'use BRANCH instead of the default branch'),
-           make_option('-c', '--count',
-                       help = 'print the number of applied patches',
-                       action = 'store_true')]
-
-
-def func(parser, options, args):
-    """Show the applied patches
-    """
-    if len(args) != 0:
-        parser.error('incorrect number of arguments')
-
-    s = directory.repository.get_stack(options.branch)
-
-    if options.count:
-        out.stdout(len(s.patchorder.applied))
-    else:
-        for pn in s.patchorder.applied:
-            out.stdout(pn)
stgit/commands/series.py +11 -2
index c11c74f..24d6ffa 100644
@@ -37,6 +37,12 @@ options = [make_option('-b', '--branch',
            make_option('-a', '--all',
                        help = 'show all patches, including the hidden ones',
                        action = 'store_true'),
+           make_option('--applied',
+                       help = 'show the applied patches only',
+                       action = 'store_true'),
+           make_option('--unapplied',
+                       help = 'show the unapplied patches only',
+                       action = 'store_true'),
            make_option('--hidden',
                        help = 'show the hidden patches only',
                        action = 'store_true'),
@@ -112,17 +118,20 @@ def func(parser, options, args):
         stack = directory.repository.get_stack(options.missing)
 
     # current series patches
+    applied = unapplied = hidden = ()
     if options.all:
         applied = stack.patchorder.applied
         unapplied = stack.patchorder.unapplied
         hidden = stack.patchorder.hidden
+    elif options.applied:
+        applied = stack.patchorder.applied
+    elif options.unapplied:
+        unapplied = stack.patchorder.unapplied
     elif options.hidden:
-        applied = unapplied = ()
         hidden = stack.patchorder.hidden
     else:
         applied = stack.patchorder.applied
         unapplied = stack.patchorder.unapplied
-        hidden = ()
 
     if options.missing:
         cmp_patches = cmp_stack.patchorder.all
stgit/commands/unapplied.py deleted +0 -50

50 lines not on this page · raw message

stgit/main.py +0 -4
index aa1f8ef..7be8e14 100644
@@ -59,7 +59,6 @@ class Commands(dict):
         return getattr(stgit.commands, cmd_mod)
 
 commands = Commands({
-    'applied':          'applied',
     'branch':           'branch',
     'delete':           'delete',
     'diff':             'diff',
@@ -96,7 +95,6 @@ commands = Commands({
     'status':           'status',
     'sync':             'sync',
     'top':              'top',
-    'unapplied':        'unapplied',
     'uncommit':         'uncommit',
     'unhide':           'unhide'
     })
@@ -107,7 +105,6 @@ repocommands = (
     'id',
     )
 stackcommands = (
-    'applied',
     'branch',
     'clean',
     'coalesce',
@@ -125,7 +122,6 @@ stackcommands = (
     'series',
     'sink',
     'top',
-    'unapplied',
     'uncommit',
     'unhide',
     )
t/t1002-branch-clone.sh +3 -3
index b0087e9..7f3f913 100755
@@ -29,16 +29,16 @@ test_expect_success \
     '
     stg branch --clone foo &&
     stg new p1 -m "p1" &&
-    test $(stg applied -c) -eq 1
+    test $(stg series --applied -c) -eq 1
     '
 
 test_expect_success \
     'Clone the current StGIT branch' \
     '
     stg branch --clone bar &&
-    test $(stg applied -c) -eq 1 &&
+    test $(stg series --applied -c) -eq 1 &&
     stg new p2 -m "p2" &&
-    test $(stg applied -c) -eq 2
+    test $(stg series --applied -c) -eq 2
     '
 
 test_done
t/t1003-new.sh +2 -2
index 0be5d9b..826e41d 100755
@@ -17,13 +17,13 @@ test_expect_success \
 test_expect_success \
     'Create a named patch' '
     stg new foo -m foobar &&
-    [ $(stg applied -c) -eq 1 ]
+    [ $(stg series --applied -c) -eq 1 ]
 '
 
 test_expect_success \
     'Create a patch without giving a name' '
     stg new -m yo &&
-    [ $(stg applied -c) -eq 2 ]
+    [ $(stg series --applied -c) -eq 2 ]
 '
 
 test_done
t/t1200-push-modified.sh +6 -6
index e3c6425..b8ca4cc 100755
@@ -26,8 +26,8 @@ test_expect_success \
         printf "a\nc\n" > file && git add file && stg refresh &&
         stg new p2 -m p2 &&
         printf "a\nb\nc\n" > file && stg refresh &&
-        [ "$(echo $(stg applied))" = "p1 p2" ] &&
-        [ "$(echo $(stg unapplied))" = "" ]
+        [ "$(echo $(stg series --applied --noprefix))" = "p1 p2" ] &&
+        [ "$(echo $(stg series --unapplied --noprefix))" = "" ]
     )
 '
 
@@ -57,8 +57,8 @@ test_expect_success \
     'Rollback the push' '
     (
         cd bar && stg push --undo &&
-        [ "$(echo $(stg applied))" = "" ] &&
-        [ "$(echo $(stg unapplied))" = "p1 p2" ]
+        [ "$(echo $(stg series --applied --noprefix))" = "" ] &&
+        [ "$(echo $(stg series --unapplied --noprefix))" = "p1 p2" ]
     )
 '
 
@@ -66,8 +66,8 @@ test_expect_success \
     'Push those patches while checking they were merged upstream' '
     (
         cd bar && stg push --merged --all
-        [ "$(echo $(stg applied))" = "p1 p2" ] &&
-        [ "$(echo $(stg unapplied))" = "" ]
+        [ "$(echo $(stg series --applied --noprefix))" = "p1 p2" ] &&
+        [ "$(echo $(stg series --unapplied --noprefix))" = "" ]
     )
 '
 
t/t1203-pop.sh +6 -6
index 6e49b4d..e1ed577 100755
@@ -12,22 +12,22 @@ test_expect_success \
     for i in 0 1 2 3 4 5 6 7 8 9; do
         stg new p$i -m p$i;
     done &&
-    [ "$(echo $(stg applied))" = "p0 p1 p2 p3 p4 p5 p6 p7 p8 p9" ] &&
-    [ "$(echo $(stg unapplied))" = "" ]
+    [ "$(echo $(stg series --applied --noprefix))" = "p0 p1 p2 p3 p4 p5 p6 p7 p8 p9" ] &&
+    [ "$(echo $(stg series --unapplied --noprefix))" = "" ]
 '
 
 test_expect_success \
     'Pop half the patches' '
     stg pop -n 5 &&
-    [ "$(echo $(stg applied))" = "p0 p1 p2 p3 p4" ] &&
-    [ "$(echo $(stg unapplied))" = "p5 p6 p7 p8 p9" ]
+    [ "$(echo $(stg series --applied --noprefix))" = "p0 p1 p2 p3 p4" ] &&
+    [ "$(echo $(stg series --unapplied --noprefix))" = "p5 p6 p7 p8 p9" ]
 '
 
 test_expect_success \
     'Pop the remaining patches' '
     stg pop -a &&
-    [ "$(echo $(stg applied))" = "" ] &&
-    [ "$(echo $(stg unapplied))" = "p0 p1 p2 p3 p4 p5 p6 p7 p8 p9" ]
+    [ "$(echo $(stg series --applied --noprefix))" = "" ] &&
+    [ "$(echo $(stg series --unapplied --noprefix))" = "p0 p1 p2 p3 p4 p5 p6 p7 p8 p9" ]
 '
 
 test_done
t/t1204-pop-keep.sh +6 -6
index 35f4ec0..db473f2 100755
@@ -11,8 +11,8 @@ test_expect_success 'Create a few patches' '
         git add patch$i.txt &&
         stg refresh
     done &&
-    [ "$(echo $(stg applied))" = "p0 p1 p2" ] &&
-    [ "$(echo $(stg unapplied))" = "" ]
+    [ "$(echo $(stg series --applied --noprefix))" = "p0 p1 p2" ] &&
+    [ "$(echo $(stg series --unapplied --noprefix))" = "" ]
 '
 
 test_expect_success 'Make some non-conflicting local changes' '
@@ -21,8 +21,8 @@ test_expect_success 'Make some non-conflicting local changes' '
 
 test_expect_success 'Pop two patches, keeping local changes' '
     stg pop -n 2 --keep &&
-    [ "$(echo $(stg applied))" = "p0" ] &&
-    [ "$(echo $(stg unapplied))" = "p1 p2" ] &&
+    [ "$(echo $(stg series --applied --noprefix))" = "p0" ] &&
+    [ "$(echo $(stg series --unapplied --noprefix))" = "p1 p2" ] &&
     [ "$(echo $(ls patch?.txt))" = "patch0.txt" ] &&
     [ "$(echo $(cat patch0.txt))" = "patch0 local" ]
 '
@@ -34,8 +34,8 @@ test_expect_success 'Reset and push patches again' '
 
 test_expect_success 'Pop a patch without local changes' '
     stg pop --keep &&
-    [ "$(echo $(stg applied))" = "p0 p1" ] &&
-    [ "$(echo $(stg unapplied))" = "p2" ] &&
+    [ "$(echo $(stg series --applied --noprefix))" = "p0 p1" ] &&
+    [ "$(echo $(stg series --unapplied --noprefix))" = "p2" ] &&
     [ "$(echo $(ls patch?.txt))" = "patch0.txt patch1.txt" ]
 '
 
t/t1205-push-subdir.sh +2 -2
index 175d36d..27d93da 100755
@@ -12,8 +12,8 @@ test_expect_success 'Create some patches' '
         git add x.txt foo/y.txt &&
         stg refresh
     done &&
-    [ "$(echo $(stg applied))" = "p0 p1 p2" ] &&
-    [ "$(echo $(stg unapplied))" = "" ]
+    [ "$(echo $(stg series --applied --noprefix))" = "p0 p1 p2" ] &&
+    [ "$(echo $(stg series --unapplied --noprefix))" = "" ]
 '
 
 test_expect_success 'Fast-forward push from a subdir' '
t/t1301-repair.sh +6 -6
index b555b93..bf4382e 100755
@@ -37,9 +37,9 @@ test_expect_success \
     '
 
 test_expect_success 'Turn one GIT commit into a patch' '
-    [ $(stg applied | wc -l) -eq 1 ] &&
+    [ $(stg series --applied -c) -eq 1 ] &&
     stg repair &&
-    [ $(stg applied | wc -l) -eq 2 ]
+    [ $(stg series --applied -c) -eq 2 ]
     '
 
 test_expect_success \
@@ -55,9 +55,9 @@ test_expect_success \
     '
 
 test_expect_success 'Turn three GIT commits into patches' '
-    [ $(stg applied | wc -l) -eq 2 ] &&
+    [ $(stg series --applied -c) -eq 2 ] &&
     stg repair &&
-    [ $(stg applied | wc -l) -eq 5 ]
+    [ $(stg series --applied -c) -eq 5 ]
     '
 
 test_expect_success \
@@ -72,9 +72,9 @@ test_expect_success \
     '
 
 test_expect_success 'Repair in the presence of a merge commit' '
-    [ $(stg applied | wc -l) -eq 5 ] &&
+    [ $(stg series --applied -c) -eq 5 ] &&
     stg repair &&
-    [ $(stg applied | wc -l) -eq 0 ]
+    [ $(stg series --applied -c) -eq 0 ]
 '
 
 test_done
t/t1302-repair-interop.sh +10 -10
index 82c5ed2..5762111 100755
@@ -21,8 +21,8 @@ test_expect_success 'Create five patches' '
     for i in 0 1 2 3 4; do
         stg new p$i -m p$i;
     done &&
-    [ "$(echo $(stg applied))" = "p0 p1 p2 p3 p4" ] &&
-    [ "$(echo $(stg unapplied))" = "" ]
+    [ "$(echo $(stg series --applied --noprefix))" = "p0 p1 p2 p3 p4" ] &&
+    [ "$(echo $(stg series --unapplied --noprefix))" = "" ]
 '
 
 test_expect_success 'Pop two patches with git-reset' '
@@ -30,14 +30,14 @@ test_expect_success 'Pop two patches with git-reset' '
     ! stg refresh &&
     stg repair &&
     stg refresh &&
-    [ "$(echo $(stg applied))" = "p0 p1 p2" ] &&
-    [ "$(echo $(stg unapplied))" = "p3 p4" ]
+    [ "$(echo $(stg series --applied --noprefix))" = "p0 p1 p2" ] &&
+    [ "$(echo $(stg series --unapplied --noprefix))" = "p3 p4" ]
 '
 
 test_expect_success 'Create a new patch' '
     stg new q0 -m q0 &&
-    [ "$(echo $(stg applied))" = "p0 p1 p2 q0" ] &&
-    [ "$(echo $(stg unapplied))" = "p3 p4" ]
+    [ "$(echo $(stg series --applied --noprefix))" = "p0 p1 p2 q0" ] &&
+    [ "$(echo $(stg series --unapplied --noprefix))" = "p3 p4" ]
 '
 
 test_expect_success 'Go to an unapplied patch with with git-reset' '
@@ -45,15 +45,15 @@ test_expect_success 'Go to an unapplied patch with with git-reset' '
     ! stg refresh &&
     stg repair &&
     stg refresh &&
-    [ "$(echo $(stg applied))" = "p0 p1 p2 p3" ] &&
-    [ "$(echo $(stg unapplied))" = "q0 p4" ]
+    [ "$(echo $(stg series --applied --noprefix))" = "p0 p1 p2 p3" ] &&
+    [ "$(echo $(stg series --unapplied --noprefix))" = "q0 p4" ]
 '
 
 test_expect_success 'Go back to below the stack base with git-reset' '
     git reset --hard foo-tag &&
     stg repair &&
-    [ "$(echo $(stg applied))" = "" ] &&
-    [ "$(echo $(stg unapplied))" = "p0 p1 p2 p3 q0 p4" ]
+    [ "$(echo $(stg series --applied --noprefix))" = "" ] &&
+    [ "$(echo $(stg series --unapplied --noprefix))" = "p0 p1 p2 p3 q0 p4" ]
 '
 
 test_done
t/t1500-float.sh +7 -7
index 778fde4..e44af3a 100755
@@ -20,37 +20,37 @@ test_expect_success \
 	 stg new F -m "f" && echo F >f.txt && git add f.txt && stg refresh &&
 	 stg new G -m "g" && echo G >g.txt && git add g.txt && stg refresh &&
 	 stg pop &&
-	 test "$(echo $(stg applied))" = "A B C D E F"
+	 test "$(echo $(stg series --applied --noprefix))" = "A B C D E F"
 	'
 
 test_expect_success \
 	'Float A to top' \
 	'stg float A &&
-	 test "$(echo $(stg applied))" = "B C D E F A"
+	 test "$(echo $(stg series --applied --noprefix))" = "B C D E F A"
 	'
 test_expect_success \
 	'Float A to top (noop)' \
 	'stg float A &&
-	 test "$(echo $(stg applied))" = "B C D E F A"
+	 test "$(echo $(stg series --applied --noprefix))" = "B C D E F A"
 	'
 test_expect_success \
 	'Float B C to top' \
 	'stg float B C &&
-	 test "$(echo $(stg applied))" = "D E F A B C"
+	 test "$(echo $(stg series --applied --noprefix))" = "D E F A B C"
 	'
 test_expect_success \
 	'Float E A to top' \
 	'stg float E A &&
-	 test "$(echo $(stg applied))" = "D F B C E A"
+	 test "$(echo $(stg series --applied --noprefix))" = "D F B C E A"
 	'
 test_expect_success \
 	'Float E to top' \
 	'stg float E &&
-	 test "$(echo $(stg applied))" = "D F B C A E"
+	 test "$(echo $(stg series --applied --noprefix))" = "D F B C A E"
 	'
 test_expect_success \
 	'Float G F to top' \
 	'stg float G F &&
-	 test "$(echo $(stg applied))" = "D B C A E G F"
+	 test "$(echo $(stg series --applied --noprefix))" = "D B C A E G F"
 	'
 test_done
t/t1600-delete-one.sh +14 -14
index c3451d8..51e4d5b 100755
@@ -19,27 +19,27 @@ test_expect_success \
 test_expect_success \
     'Try to delete a non-existing patch' \
     '
-    [ $(stg applied | wc -l) -eq 1 ] &&
+    [ $(stg series --applied -c) -eq 1 ] &&
     ! stg delete bar &&
-    [ $(stg applied | wc -l) -eq 1 ]
+    [ $(stg series --applied -c) -eq 1 ]
     '
 
 test_expect_success \
     'Try to delete the topmost patch while dirty' \
     '
     echo dirty >> foo.txt &&
-    [ $(stg applied | wc -l) -eq 1 ] &&
+    [ $(stg series --applied -c) -eq 1 ] &&
     ! stg delete foo &&
-    [ $(stg applied | wc -l) -eq 1 ] &&
+    [ $(stg series --applied -c) -eq 1 ] &&
     git reset --hard
     '
 
 test_expect_success \
     'Delete the topmost patch' \
     '
-    [ $(stg applied | wc -l) -eq 1 ] &&
+    [ $(stg series --applied -c) -eq 1 ] &&
     stg delete foo &&
-    [ $(stg applied | wc -l) -eq 0 ]
+    [ $(stg series --applied -c) -eq 0 ]
     '
 
 test_expect_success \
@@ -55,9 +55,9 @@ test_expect_success \
 test_expect_success \
     'Delete an unapplied patch' \
     '
-    [ $(stg unapplied | wc -l) -eq 1 ] &&
+    [ $(stg series --unapplied -c) -eq 1 ] &&
     stg delete foo &&
-    [ $(stg unapplied | wc -l) -eq 0 ]
+    [ $(stg series --unapplied -c) -eq 0 ]
     '
 
 test_expect_success \
@@ -76,9 +76,9 @@ test_expect_success \
 test_expect_success \
     'Try to delete a non-topmost applied patch' \
     '
-    [ $(stg applied | wc -l) -eq 2 ] &&
+    [ $(stg series --applied -c) -eq 2 ] &&
     stg delete foo &&
-    [ $(stg applied | wc -l) -eq 1 ]
+    [ $(stg series --applied -c) -eq 1 ]
     '
 
 test_expect_success \
@@ -99,11 +99,11 @@ test_expect_success \
 test_expect_success \
     'Delete a patch in another branch' \
     '
-    [ $(stg applied | wc -l) -eq 2 ] &&
-    [ $(stg applied -b br | wc -l) -eq 1 ] &&
+    [ $(stg series --applied -c) -eq 2 ] &&
+    [ $(stg series --applied -b br -c) -eq 1 ] &&
     stg delete -b br baz &&
-    [ $(stg applied | wc -l) -eq 2 ] &&
-    [ $(stg applied -b br | wc -l) -eq 0 ]
+    [ $(stg series --applied -c) -eq 2 ] &&
+    [ $(stg series --applied -b br -c) -eq 0 ]
     '
 
 test_done
t/t1601-delete-many.sh +12 -12
index 30b0a1d..a254980 100755
@@ -25,31 +25,31 @@ test_expect_success \
 test_expect_success \
     'Delete some patches' \
     '
-    [ "$(echo $(stg applied))" = "p0 p1 p2 p3 p4" ] &&
-    [ "$(echo $(stg unapplied))" = "p5 p6 p7 p8 p9" ] &&
+    [ "$(echo $(stg series --applied --noprefix))" = "p0 p1 p2 p3 p4" ] &&
+    [ "$(echo $(stg series --unapplied --noprefix))" = "p5 p6 p7 p8 p9" ] &&
     stg delete p7 p6 p3 p4 &&
-    [ "$(echo $(stg applied))" = "p0 p1 p2" ] &&
-    [ "$(echo $(stg unapplied))" = "p5 p8 p9" ]
+    [ "$(echo $(stg series --applied --noprefix))" = "p0 p1 p2" ] &&
+    [ "$(echo $(stg series --unapplied --noprefix))" = "p5 p8 p9" ]
     '
 
 test_expect_success \
     'Delete some more patches, some of which do not exist' \
     '
-    [ "$(echo $(stg applied))" = "p0 p1 p2" ] &&
-    [ "$(echo $(stg unapplied))" = "p5 p8 p9" ] &&
+    [ "$(echo $(stg series --applied --noprefix))" = "p0 p1 p2" ] &&
+    [ "$(echo $(stg series --unapplied --noprefix))" = "p5 p8 p9" ] &&
     ! stg delete p7 p8 p2 p0 &&
-    [ "$(echo $(stg applied))" = "p0 p1 p2" ] &&
-    [ "$(echo $(stg unapplied))" = "p5 p8 p9" ]
+    [ "$(echo $(stg series --applied --noprefix))" = "p0 p1 p2" ] &&
+    [ "$(echo $(stg series --unapplied --noprefix))" = "p5 p8 p9" ]
     '
 
 test_expect_success \
     'Delete a range of patches' \
     '
-    [ "$(echo $(stg applied))" = "p0 p1 p2" ] &&
-    [ "$(echo $(stg unapplied))" = "p5 p8 p9" ] &&
+    [ "$(echo $(stg series --applied --noprefix))" = "p0 p1 p2" ] &&
+    [ "$(echo $(stg series --unapplied --noprefix))" = "p5 p8 p9" ] &&
     stg delete p1..p8 &&
-    [ "$(echo $(stg applied))" = "p0" ] &&
-    [ "$(echo $(stg unapplied))" = "p9" ]
+    [ "$(echo $(stg series --applied --noprefix))" = "p0" ] &&
+    [ "$(echo $(stg series --unapplied --noprefix))" = "p9" ]
     '
 
 test_done
t/t2000-sync.sh +24 -24

113 lines not on this page · raw message

t/t2200-rebase.sh +2 -2
index cd43c41..12b4af6 100755
@@ -28,7 +28,7 @@ test_expect_success \
 	'
 	stg rebase master~1 &&
 	test `stg id stack:{base}` = `git rev-parse master~1` &&
-	test `stg applied | wc -l` = 1
+	test `stg series --applied -c` = 1
 	'
 
 test_expect_success \
@@ -40,7 +40,7 @@ test_expect_success \
 test_expect_success \
 	'Check patches were re-applied' \
 	'
-	test $(stg applied | wc -l) = 1
+	test $(stg series --applied -c) = 1
 	'
 
 test_done
t/t2500-clean.sh +6 -6
index ad8f892..063572b 100755
@@ -17,11 +17,11 @@ test_expect_success 'Initialize StGit stack' '
 '
 
 test_expect_success 'Clean empty patches' '
-    [ "$(echo $(stg applied))" = "e0 p0 e1" ] &&
-    [ "$(echo $(stg unapplied))" = "e2" ] &&
+    [ "$(echo $(stg series --applied --noprefix))" = "e0 p0 e1" ] &&
+    [ "$(echo $(stg series --unapplied --noprefix))" = "e2" ] &&
     stg clean &&
-    [ "$(echo $(stg applied))" = "p0" ] &&
-    [ "$(echo $(stg unapplied))" = "" ]
+    [ "$(echo $(stg series --applied --noprefix))" = "p0" ] &&
+    [ "$(echo $(stg series --unapplied --noprefix))" = "" ]
 '
 
 test_expect_success 'Create a conflict' '
@@ -37,8 +37,8 @@ test_expect_success 'Create a conflict' '
 
 test_expect_success 'Make sure conflicting patches are preserved' '
     stg clean &&
-    [ "$(echo $(stg applied))" = "p0 p2 p1" ] &&
-    [ "$(echo $(stg unapplied))" = "" ]
+    [ "$(echo $(stg series --applied --noprefix))" = "p0 p2 p1" ] &&
+    [ "$(echo $(stg series --unapplied --noprefix))" = "" ]
 '
 
 test_done
t/t2600-coalesce.sh +6 -6
index f13a309..ef5bf99 100755
@@ -15,17 +15,17 @@ test_expect_success 'Initialize StGit stack' '
 '
 
 test_expect_success 'Coalesce some patches' '
-    [ "$(echo $(stg applied))" = "p0 p1 p2 p3" ] &&
-    [ "$(echo $(stg unapplied))" = "" ] &&
+    [ "$(echo $(stg series --applied --noprefix))" = "p0 p1 p2 p3" ] &&
+    [ "$(echo $(stg series --unapplied --noprefix))" = "" ] &&
     stg coalesce --name=q0 --message="wee woo" p1 p2 &&
-    [ "$(echo $(stg applied))" = "p0 q0 p3" ] &&
-    [ "$(echo $(stg unapplied))" = "" ]
+    [ "$(echo $(stg series --applied --noprefix))" = "p0 q0 p3" ] &&
+    [ "$(echo $(stg series --unapplied --noprefix))" = "" ]
 '
 
 test_expect_success 'Coalesce at stack top' '
     stg coalesce --name=q1 --message="wee woo wham" q0 p3 &&
-    [ "$(echo $(stg applied))" = "p0 q1" ] &&
-    [ "$(echo $(stg unapplied))" = "" ]
+    [ "$(echo $(stg series --applied --noprefix))" = "p0 q1" ] &&
+    [ "$(echo $(stg series --unapplied --noprefix))" = "" ]
 '
 
 test_done
t/t3000-dirty-merge.sh +4 -4
index d87bba1..a4e228a 100755
@@ -24,11 +24,11 @@ test_expect_success 'Pop one patch and update the other' '
 
 test_expect_success 'Push with dirty worktree' '
     echo 4 > a &&
-    [ "$(echo $(stg applied))" = "p1" ] &&
-    [ "$(echo $(stg unapplied))" = "p2" ] &&
+    [ "$(echo $(stg series --applied --noprefix))" = "p1" ] &&
+    [ "$(echo $(stg series --unapplied --noprefix))" = "p2" ] &&
     ! stg goto p2 &&
-    [ "$(echo $(stg applied))" = "p1" ] &&
-    [ "$(echo $(stg unapplied))" = "p2" ] &&
+    [ "$(echo $(stg series --applied --noprefix))" = "p1" ] &&
+    [ "$(echo $(stg series --unapplied --noprefix))" = "p2" ] &&
     [ "$(echo $(cat a))" = "4" ]
 '
 
t/t4000-upgrade.sh +2 -2
index 8a308fb..01fe248 100755
@@ -14,8 +14,8 @@ for ver in 0.12 0.8; do
 
     test_expect_success \
         "v$ver: Check the list of applied and unapplied patches" '
-        [ "$(echo $(stg applied))" = "p0 p1 p2" ] &&
-        [ "$(echo $(stg unapplied))" = "p3 p4" ]
+        [ "$(echo $(stg series --applied --noprefix))" = "p0 p1 p2" ] &&
+        [ "$(echo $(stg series --unapplied --noprefix))" = "p3 p4" ]
     '
 
     test_expect_success \
#11 lore raw

Re: [StGIT PATCH 4/4] Remove the applied/unapplied commands

Quoted 2 lines · Catalin Marinas

This patch moves the applied/unapplied functionality to the 'series' command via the corresponding options.

Nice.

stgit/commands/series.py options = [make_option('-b', '--branch', · line 48

Quoted 12 lines
            make_option('-a', '--all',
                        help = 'show all patches, including the hidden ones',
                        action = 'store_true'),
stgit/commands/series.py +6 -0
+           make_option('--applied',
+                       help = 'show the applied patches only',
+                       action = 'store_true'),
+           make_option('--unapplied',
+                       help = 'show the unapplied patches only',
+                       action = 'store_true'),
            make_option('--hidden',
                        help = 'show the hidden patches only',
                        action = 'store_true'),

Maybe some logic to prohibit the use of more than one of these at once? The current logic is kind of arbitrary.

Also, we should perhaps invent good single-letter abbreviations for these presumably rather common flags. -a is taken; -A and -U perhaps?

Signature · 2 lines
Karl Hasselström, [email protected]
      www.treskal.com/kalle
#12 lore raw

Re: [StGIT PATCH 4/4] Remove the applied/unapplied commands

2008/6/22 Karl Hasselström <[email protected]>:

Quoted 4 lines · Catalin Marinas
Quoted 3 lines

This patch moves the applied/unapplied functionality to the 'series' command via the corresponding options.

[...]

Quoted 13 lines

stgit/commands/series.py options = [make_option('-b', '--branch', · line 48

Quoted 12 lines
            make_option('-a', '--all',
                        help = 'show all patches, including the hidden ones',
                        action = 'store_true'),
stgit/commands/series.py +6 -0
+           make_option('--applied',
+                       help = 'show the applied patches only',
+                       action = 'store_true'),
+           make_option('--unapplied',
+                       help = 'show the unapplied patches only',
+                       action = 'store_true'),
            make_option('--hidden',
                        help = 'show the hidden patches only',
                        action = 'store_true'),
Quoted 2 lines

Maybe some logic to prohibit the use of more than one of these at once? The current logic is kind of arbitrary.

I decided to allow a combination of applied/unapplied/hidden but not together with all. I'll post the patches again.

Signature · 1 line
Catalin