Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 5 additions & 6 deletions svn/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -242,10 +242,6 @@ def log_default(self, timestamp_from_dt=None, timestamp_to_dt=None,
do_combine=True)

root = xml.etree.ElementTree.fromstring(result)
named_fields = ['date', 'msg', 'revision', 'author', 'changelist']
c = collections.namedtuple(
'LogEntry',
named_fields)

# Merge history can create nested log entries, so use iter instead of findall
for e in root.iter('logentry'):
Expand All @@ -266,13 +262,16 @@ def log_default(self, timestamp_from_dt=None, timestamp_to_dt=None,
if changelist is True:
cl = []
for ch in e.findall('paths/path'):
cl.append((ch.attrib['action'], ch.text))
# namedtuple fields cannot have hyphens, so replace with underscores
attribs = svn.constants.ChangelistEntryDefaults.copy()
attribs.update({key.replace('-', '_'): val for key, val in ch.attrib.items()})
cl.append(svn.constants.ChangelistEntry(path=ch.text, **attribs))

log_entry['changelist'] = cl
else:
log_entry['changelist'] = None

yield c(**log_entry)
yield svn.constants.LogEntry(**log_entry)

def export(self, to_path, revision=None, force=False):
cmd = []
Expand Down
12 changes: 12 additions & 0 deletions svn/constants.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import collections

# Kinds

K_DIR = 'dir'
Expand Down Expand Up @@ -43,3 +45,13 @@
'replaced': ST_REPLACED,
'unversioned': ST_UNVERSIONED,
}

fields = ['date', 'msg', 'revision', 'author', 'changelist']
LogEntry = collections.namedtuple('LogEntry', fields)

# <path> code in https://svn.apache.org/repos/asf/subversion/trunk/subversion/svn/log-cmd.c
# uses hyphens for the attribute names, but namedtuple field names cannot have hyphens
fields = ['action', 'path', 'copyfrom_path', 'copyfrom_rev', 'kind', 'text_mods', 'prop_mods']
ChangelistEntry = collections.namedtuple('ChangelistEntry', fields)
# NOTE: Python 2's namedtuple doesn't allow for defaults, so need a defaults dict
ChangelistEntryDefaults = {x: None for x in fields[2:]}