Add the --unrelated option to mail
[stgit] / stgit / git.py
index 4bc41aa..1f57481 100644 (file)
@@ -158,7 +158,7 @@ def _input(cmd, file_desc):
         p.tochild.write(line)
     p.tochild.close()
     if p.wait():
-        raise GitException, '%s failed (%s)' % (str(cmd),
+        raise GitException, '%s failed (%s)' % (' '.join(cmd),
                                                 p.childerr.read().strip())
 
 def _input_str(cmd, string):
@@ -166,14 +166,14 @@ def _input_str(cmd, string):
     p.tochild.write(string)
     p.tochild.close()
     if p.wait():
-        raise GitException, '%s failed (%s)' % (str(cmd),
+        raise GitException, '%s failed (%s)' % (' '.join(cmd),
                                                 p.childerr.read().strip())
 
 def _output(cmd):
     p=popen2.Popen3(cmd, True)
     output = p.fromchild.read()
     if p.wait():
-        raise GitException, '%s failed (%s)' % (str(cmd),
+        raise GitException, '%s failed (%s)' % (' '.join(cmd),
                                                 p.childerr.read().strip())
     return output
 
@@ -185,7 +185,7 @@ def _output_one_line(cmd, file_desc = None):
         p.tochild.close()
     output = p.fromchild.readline().strip()
     if p.wait():
-        raise GitException, '%s failed (%s)' % (str(cmd),
+        raise GitException, '%s failed (%s)' % (' '.join(cmd),
                                                 p.childerr.read().strip())
     return output
 
@@ -193,7 +193,7 @@ def _output_lines(cmd):
     p=popen2.Popen3(cmd, True)
     lines = p.fromchild.readlines()
     if p.wait():
-        raise GitException, '%s failed (%s)' % (str(cmd),
+        raise GitException, '%s failed (%s)' % (' '.join(cmd),
                                                 p.childerr.read().strip())
     return lines
 
@@ -216,7 +216,7 @@ def __run(cmd, args=None):
         return r
     return 0
 
-def __tree_status(files = None, tree_id = 'HEAD', unknown = False,
+def tree_status(files = None, tree_id = 'HEAD', unknown = False,
                   noexclude = True, verbose = False, diff_flags = []):
     """Returns a list of pairs - [status, filename]
     """
@@ -268,7 +268,7 @@ def __tree_status(files = None, tree_id = 'HEAD', unknown = False,
 def local_changes(verbose = True):
     """Return true if there are local changes in the tree
     """
-    return len(__tree_status(verbose = verbose)) != 0
+    return len(tree_status(verbose = verbose)) != 0
 
 # HEAD value cached
 __head = None
@@ -567,7 +567,7 @@ def update_cache(files = None, force = False):
     if not files:
         files = []
 
-    cache_files = __tree_status(files, verbose = False)
+    cache_files = tree_status(files, verbose = False)
 
     # everything is up-to-date
     if len(cache_files) == 0:
@@ -745,7 +745,7 @@ def status(files = None, modified = False, new = False, deleted = False,
     if not files:
         files = []
 
-    cache_files = __tree_status(files, unknown = True, noexclude = noexclude,
+    cache_files = tree_status(files, unknown = True, noexclude = noexclude,
                                 diff_flags = diff_flags)
     all = not (modified or new or deleted or conflict or unknown)
 
@@ -876,7 +876,7 @@ def reset(files = None, tree_id = None, check_out = True):
         tree_id = get_head()
 
     if check_out:
-        cache_files = __tree_status(files, tree_id)
+        cache_files = tree_status(files, tree_id)
         # files which were added but need to be removed
         rm_files =  [x[1] for x in cache_files if x[0] in ['A']]
 
@@ -1070,3 +1070,9 @@ def fetch_head():
 
     # here we are sure to have a single fetch_head
     return fetch_head
+
+def all_refs():
+    """Return a list of all refs in the current repository.
+    """
+
+    return [line.split()[1] for line in _output_lines(['git-show-ref'])]