Rudimentary support for multiple development branches
[stgit] / stgit / commands / common.py
index 68bd39b..f9e2a28 100644 (file)
@@ -92,32 +92,45 @@ def check_conflicts():
     if os.path.exists(os.path.join(git.base_dir, 'conflicts')):
         raise CmdException, 'Unsolved conflicts. Please resolve them first'
 
-def print_crt_patch():
-    patch = crt_series.get_current()
+def print_crt_patch(branch = None):
+    if not branch:
+        patch = crt_series.get_current()
+    else:
+        patch = stack.Series(branch).get_current()
+
     if patch:
         print 'Now at patch "%s"' % patch
     else:
         print 'No patches applied'
 
-def resolved(filename):
+def resolved(filename, reset = None):
+    if reset:
+        reset_file = filename + '.' + reset
+        if os.path.isfile(reset_file):
+            if os.path.isfile(filename):
+                os.remove(filename)
+            os.rename(reset_file, filename)
+
     git.update_cache([filename], force = True)
+
     for ext in ['.local', '.older', '.remote']:
         fn = filename + ext
         if os.path.isfile(fn):
             os.remove(fn)
 
-def resolved_all():
+def resolved_all(reset = None):
     conflicts = git.get_conflicts()
     if conflicts:
         for filename in conflicts:
-            resolved(filename)
+            resolved(filename, reset)
         os.remove(os.path.join(git.base_dir, 'conflicts'))
 
 def name_email(string):
     """Return a tuple consisting of the name and email parsed from a
     standard 'name <email>' string
     """
-    str_list = re.findall('^(.*)\s+<(.*)>$', string)
+    string = re.sub('([^\w\s<>@.])', '\\\\\\1', string)
+    str_list = re.findall('^(.*)\s*<(.*)>\s*$', string)
     if not str_list:
         raise CmdException, 'Incorrect "name <email>" string: %s' % string
 
@@ -127,7 +140,8 @@ def name_email_date(string):
     """Return a tuple consisting of the name, email and date parsed
     from a 'name <email> date' string
     """
-    str_list = re.findall('^(.*)\s+<(.*)>\s+(.*)$', string)
+    string = re.sub('([^\w\s<>@.])', '\\\\\\1', string)
+    str_list = re.findall('^(.*)\s*<(.*)>\s*(.*)\s*$', string)
     if not str_list:
         raise CmdException, 'Incorrect "name <email> date" string: %s' % string