chiark / gitweb /
Add a boundary to parse_patches()
authorCatalin Marinas <catalin.marinas@gmail.com>
Wed, 22 Nov 2006 20:14:58 +0000 (20:14 +0000)
committerCatalin Marinas <catalin.marinas@gmail.com>
Wed, 22 Nov 2006 20:14:58 +0000 (20:14 +0000)
This is useful since specifying the ".." range would generate all the
applied and unapplied patches for commands like "show" and
"delete". With this patch, the boundary is crossed only if
specifically asked (i.e. the first and last patch of the range are on
each side of the boundary).

Signed-off-by: Catalin Marinas <catalin.marinas@gmail.com>
stgit/commands/common.py
stgit/commands/delete.py
stgit/commands/show.py

index 4e802bc20821c1aa5a7c90d71a086026dc888229..723fc5b2692b48020f3d08fee914423d4d142b4d 100644 (file)
@@ -214,7 +214,7 @@ def pop_patches(patches, keep = False):
 
         print 'done'
 
-def parse_patches(patch_args, patch_list):
+def parse_patches(patch_args, patch_list, boundary = 0):
     """Parse patch_args list for patch names in patch_list and return
     a list. The names can be individual patches and/or in the
     patch1..patch2 format.
@@ -236,12 +236,26 @@ def parse_patches(patch_args, patch_list):
             if pair[0]:
                 first = patch_list.index(pair[0])
             else:
-                first = 0
+                first = -1
             # exclusive boundary
             if pair[1]:
                 last = patch_list.index(pair[1]) + 1
             else:
-                last = len(patch_list)
+                last = -1
+
+            # only cross the boundary if explicitly asked
+            if not boundary:
+                boundary = len(patch_list)
+            if first < 0:
+                if last <= boundary:
+                    first = 0
+                else:
+                    first = boundary
+            if last < 0:
+                if first < boundary:
+                    last = boundary
+                else:
+                    last = len(patch_list)
 
             if last > first:
                 pl = patch_list[first:last]
index 515f4b7048e1978b2ee9cb2f3579a102b2b8cdb1..e1a70c93f8f89974699938b0c98d9ba40cbc4af2 100644 (file)
@@ -46,7 +46,7 @@ def func(parser, options, args):
     all_patches = applied_patches + unapplied_patches
 
     if args:
-        patches = parse_patches(args, all_patches)
+        patches = parse_patches(args, all_patches, len(applied_patches))
     else:
         parser.error('No patches specified')
 
index 5c297c0959560e18705c6a9aa3cb71eff43a4853..a270efd8bd99f48d6b0744226ce7a33b11182439 100644 (file)
@@ -41,10 +41,13 @@ options = [make_option('-a', '--applied',
 def func(parser, options, args):
     """Show commit log and diff
     """
+    applied = crt_series.get_applied()
+    unapplied = crt_series.get_unapplied()
+
     if options.applied:
-        patches = crt_series.get_applied()
+        patches = applied
     elif options.unapplied:
-        patches = crt_series.get_unapplied()
+        patches = unapplied
     elif len(args) == 0:
         patches = ['HEAD']
     else:
@@ -53,8 +56,7 @@ def func(parser, options, args):
             # it might be just a commit id
             patches = args
         else:
-            patches = parse_patches(args, crt_series.get_applied()
-                                    + crt_series.get_unapplied())
+            patches = parse_patches(args, applied + unapplied, len(applied))
 
     commit_ids = [git_id(patch) for patch in patches]
     commit_str = '\n'.join([git.pretty_commit(commit_id)