From e078133e1145fc63235c59527f6a36e8f30d03c1 Mon Sep 17 00:00:00 2001 From: Catalin Marinas Date: Fri, 23 Feb 2007 22:09:06 +0000 Subject: [PATCH] Add --branch option to 'patches' Signed-off-by: Catalin Marinas --- stgit/commands/patches.py | 7 +++++-- stgit/git.py | 4 ++-- stgit/stack.py | 9 +++++++++ 3 files changed, 16 insertions(+), 4 deletions(-) diff --git a/stgit/commands/patches.py b/stgit/commands/patches.py index 7da74ba8..0b3c46f3 100644 --- a/stgit/commands/patches.py +++ b/stgit/commands/patches.py @@ -32,7 +32,9 @@ option also lists the patch log and the diff for the given files.""" options = [make_option('-d', '--diff', help = 'show the diff for the given files', - action = 'store_true')] + action = 'store_true'), + make_option('-b', '--branch', + help = 'use BRANCH instead of the default one')] diff_tmpl = \ '-------------------------------------------------------------------------------\n' \ @@ -52,7 +54,8 @@ def func(parser, options, args): if not applied: raise CmdException, 'No patches applied' - revs = git.modifying_revs(args, git_id('base')) + revs = git.modifying_revs(args, crt_series.get_base(), + crt_series.get_head()) revs.reverse() # build the patch/revision mapping diff --git a/stgit/git.py b/stgit/git.py index 458eb97a..f9094cda 100644 --- a/stgit/git.py +++ b/stgit/git.py @@ -891,10 +891,10 @@ def clone(repository, local_dir): raise GitException, 'Failed "git-clone %s %s"' \ % (repository, local_dir) -def modifying_revs(files, base_rev): +def modifying_revs(files, base_rev, head_rev): """Return the revisions from the list modifying the given files """ - cmd = ['git-rev-list', '%s..' % base_rev, '--'] + cmd = ['git-rev-list', '%s..%s' % (base_rev, head_rev), '--'] revs = [line.strip() for line in _output_lines(cmd + files)] return revs diff --git a/stgit/stack.py b/stgit/stack.py index 0f5d868d..99f10e54 100644 --- a/stgit/stack.py +++ b/stgit/stack.py @@ -397,6 +397,15 @@ class Series(StgitObject): def get_base(self): return read_string(self.get_base_file()) + def get_head(self): + """Return the head of the branch + """ + crt = self.get_current_patch() + if crt: + return crt.get_top() + else: + return self.get_base() + def get_protected(self): return os.path.isfile(os.path.join(self._dir(), 'protected')) -- 2.11.4.GIT