xblog-upgrade-to-svn-1.4.diff
Index: xblog/xblog
===================================================================
--- xblog/xblog (revision 58)
+++ xblog/xblog (working copy)
@@ -151,13 +151,11 @@
ET = None
Template = None
-### "cached" ET trees of .svn/entries data and some metainfo about those files
-svn_entry_files = {}
+### some metainfo about (faked since 1.4) .svn/entries data
svn_entry_attribs = ["commited-rev", "name", "committed-date",
"url", "last-author", "kind", "prop-time",
"revision"]
svn_entry_isotime_attribs = ["committed-date", "prop-time"]
-svn_entry_files_max_cache = 100
### "cached" hashes of (svn) propertiess
svn_property_cache = {}
@@ -403,7 +401,7 @@
def __svn_get_info(source_path):
"""Get the attributes of the .svn/entries file associated with this file
as a python hash."""
- global svn_entry_files, ET, svn_entry_isotime_attribs, svn_entry_files_max_cache
+ global ET, XML, svn_entry_isotime_attribs
containing_dir = dirname(source_path)
filename = basename(source_path)
@@ -411,26 +409,51 @@
if not exists(entry_file):
return {}
- if svn_entry_files.has_key(entry_file):
- doc = svn_entry_files[entry_file]
- else:
- doc = ET.parse(entry_file)
- svn_entry_files[entry_file] = doc
+ p=Popen(['svn', 'info', '--xml', '--non-interactive',
+ filename], env=ENV, shell=False,
+ cwd=containing_dir, stdout=PIPE)
+ data=p.communicate()[0]
+ if p.returncode != 0:
+ print "Warning: svn info on %s failed with exitcode %s" % (source_path,p.returncode)
+ return {}
- entries = doc.getroot().getchildren()
- dir_info = {}
+ doc = ET.XML(data)
+
+ entry = doc.find("entry")
+ if not entry:
+ return {}
+
file_info = {}
- for e in entries:
- if e.attrib["name"] == "":
- dir_info = e.attrib
- continue
- if e.attrib["name"] == filename:
- file_info = e.attrib
- continue
+ commit = entry.find("commit")
+ if commit != None:
+ file_info["committed-rev"] = commit.attrib["revision"]
+ file_info["name"] = entry.attrib["path"]
+ text_updated = entry.find("wc-info/text-updated")
+ if text_updated != None:
+ file_info["text-time"] = text_updated.text
+ if commit != None:
+ commit_date = commit.find("date")
+ if commit_date != None:
+ file_info["committed-date"] = commit_date.text
+ url = entry.find("url")
+ if url != None:
+ file_info["url"] = url.text
+ checksum = entry.find("wc-info/checksum")
+ if checksum != None:
+ file_info["checksum"] = checksum.text
+ if commit != None:
+ commit_author = commit.find("author")
+ if commit_author != None:
+ file_info["last-author"] = commit_author.text
+ file_info["kind"] = entry.attrib["kind"]
+ uuid = entry.find("repository/uuid")
+ if uuid != None:
+ file_info["uuid"] = uuid.text
+ prop_updated = entry.find("wc-info/prop-updated")
+ if prop_updated != None:
+ file_info["prop-time"] = prop_updated.text
+ file_info["revision"] = entry.attrib["revision"]
- if not file_info.has_key("url") and dir_info.has_key("url"):
- file_info["url"] = "%s/%s" % (dir_info["url"], filename)
-
# we create a seperate copy from ET since we (might) need a 'real' dict
file_info = dict(file_info)
@@ -438,12 +461,6 @@
if file_info.has_key(k):
file_info[k] = parse_iso8601(file_info[k])
- # control memory use
- if len(svn_entry_files) > svn_entry_files_max_cache:
- svn_entry_files.clear()
- import gc
- gc.collect()
-
return file_info