Add --branch option to 'patches'
authorCatalin Marinas <catalin.marinas@gmail.com>
Fri, 23 Feb 2007 22:09:06 +0000 (22:09 +0000)
committerCatalin Marinas <catalin.marinas@gmail.com>
Fri, 23 Feb 2007 22:09:06 +0000 (22:09 +0000)
Signed-off-by: Catalin Marinas <catalin.marinas@gmail.com>
stgit/commands/patches.py
stgit/git.py
stgit/stack.py

index 7da74ba..0b3c46f 100644 (file)
@@ -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
index 458eb97..f9094cd 100644 (file)
@@ -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
index 0f5d868..99f10e5 100644 (file)
@@ -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'))