diff options
author | W. Trevor King <wking@drexel.edu> | 2009-07-27 08:12:16 -0400 |
---|---|---|
committer | W. Trevor King <wking@drexel.edu> | 2009-07-27 08:12:16 -0400 |
commit | 675aa10516d1fe2a5f0502be5553e38169f444c0 (patch) | |
tree | cb19b2ee621cd1120ae9afdafe6f52ee70137a32 /libbe/darcs.py | |
parent | 885b04b50ad3bbde81ec2eccfbfb2e516d0d3a80 (diff) | |
parent | 7f2ee356b76303edd01efad6bd049fbc7f01b5ff (diff) | |
download | bugseverywhere-675aa10516d1fe2a5f0502be5553e38169f444c0.tar.gz |
Merged "be subscribe" and be-handle-mail subscription support.
Also assorted other changes and fixes in the be.subscribe branch.
Highlights:
* Much more powerful libbe.diff with subclassable report generators.
* "be diff" compares working copy with last commit by default.
* comment reference text shown in "be comment" EDITOR footer
* .revision_id() for all VCSs
* meaningful comment comparison and stricter bug comparison
* stricter .sync_with_disk interpretation. See BugDir.__doc__.
* Comment.From and .time_string -> .author and .date, for better
conformance with settings_object.setting_name_to_attr_name().
Diffstat (limited to 'libbe/darcs.py')
-rw-r--r-- | libbe/darcs.py | 43 |
1 files changed, 30 insertions, 13 deletions
diff --git a/libbe/darcs.py b/libbe/darcs.py index e7132c0..0720ed9 100644 --- a/libbe/darcs.py +++ b/libbe/darcs.py @@ -18,8 +18,13 @@ import codecs import os import re import sys -import unittest +try: # import core module, Python >= 2.5 + from xml.etree import ElementTree +except ImportError: # look for non-core module + from elementtree import ElementTree +from xml.sax.saxutils import unescape import doctest +import unittest import rcs from rcs import RCS @@ -138,24 +143,36 @@ class Darcs(RCS): args = ['record', '--all', '--author', id, '--logfile', commitfile] status,output,error = self._u_invoke_client(*args) empty_strings = ["No changes!"] - revision = None if self._u_any_in_string(empty_strings, output) == True: if allow_empty == False: raise rcs.EmptyCommit() - else: # we need a extra call to get the current revision - args = ["changes", "--last=1", "--xml"] - status,output,error = self._u_invoke_client(*args) - revline = re.compile("[ \t]*<name>(.*)</name>") - # note that darcs does _not_ make an empty revision. - # this returns the last non-empty revision id... + # note that darcs does _not_ make an empty revision. + # this returns the last non-empty revision id... + revision = self._rcs_revision_id(-1) else: revline = re.compile("Finished recording patch '(.*)'") - match = revline.search(output) - assert match != None, output+error - assert len(match.groups()) == 1 - revision = match.groups()[0] + match = revline.search(output) + assert match != None, output+error + assert len(match.groups()) == 1 + revision = match.groups()[0] return revision - + def _rcs_revision_id(self, index): + status,output,error = self._u_invoke_client("changes", "--xml") + revisions = [] + xml_str = output.encode("unicode_escape").replace(r"\n", "\n") + element = ElementTree.XML(xml_str) + assert element.tag == "changelog", element.tag + for patch in element.getchildren(): + assert patch.tag == "patch", patch.tag + for child in patch.getchildren(): + if child.tag == "name": + text = unescape(unicode(child.text).decode("unicode_escape").strip()) + revisions.append(text) + revisions.reverse() + try: + return revisions[index] + except IndexError: + return None rcs.make_rcs_testcase_subclasses(Darcs, sys.modules[__name__]) |