Pass -q to git-merge-cache
[stgit] / stgit / commands / common.py
index 6193eb0..86f62fb 100644 (file)
@@ -18,7 +18,7 @@ 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
+import sys, os, re
 from optparse import OptionParser, make_option
 
 from stgit.utils import *
@@ -30,12 +30,8 @@ class CmdException(Exception):
     pass
 
 
-# Global variables
-crt_series = stack.Series()
-
-
 # Utility functions
-def git_id(string):
+def git_id(string, strict = False):
     """Return the GIT id
     """
     if not string:
@@ -57,6 +53,10 @@ def git_id(string):
             id_file = os.path.join(path, git_id)
             if os.path.isfile(id_file):
                 return read_string(id_file)
+
+        # maybe GIT knows more about this id
+        if not strict:
+            return git_id
     elif len(string_list) == 2:
         patch_name = string_list[0]
         if patch_name == '':
@@ -100,7 +100,7 @@ def print_crt_patch():
         print 'No patches applied'
 
 def resolved(filename):
-    git.update_cache([filename])
+    git.update_cache([filename], force = True)
     for ext in ['.local', '.older', '.remote']:
         fn = filename + ext
         if os.path.isfile(fn):
@@ -112,3 +112,13 @@ def resolved_all():
         for filename in conflicts:
             resolved(filename)
         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
+    """
+    names = re.split('([^<>]*)<([^<>]*)>', string)
+    if len(names) != 4:
+        raise CmdException, 'Incorrect "name <email>" string: %s' % string
+
+    return tuple([names[1].strip(), names[2].strip()])