Skip to content

Commit

Permalink
Allow topic as commit message info
Browse files Browse the repository at this point in the history
  • Loading branch information
misery committed Aug 8, 2024
1 parent c8ff15c commit f6fcf31
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions contrib/mercurial_git_push.py
Original file line number Diff line number Diff line change
Expand Up @@ -1212,6 +1212,7 @@ def __init__(self):
class BaseRevision(object):
def __init__(self):
self._summary = None
self._topic = None

def summary(self):
if self._summary is None:
Expand All @@ -1227,6 +1228,17 @@ def mail(self):
def authorName(self):
return re.sub(r'<.*>', '', self.author()).strip()

def topic(self):
if self._topic is None:
matches = re.findall(r'^topic:([a-z|A-Z|0-9|/| ]+)',
self.desc(), re.MULTILINE)
if len(matches) > 0:
self._topic = matches[-1].strip()
else:
self._topic = ""

return None if self._topic == "" else self._topic


class MercurialRevision(BaseRevision):
"""Class to represent information of changeset."""
Expand Down Expand Up @@ -1269,7 +1281,7 @@ def topic(self):
if 'extra' in self.json and 'topic' in self.json['extra']:
return self.json['extra']['topic']

return None
return super(MercurialRevision, self).topic()

def graft(self, short=True):
if self._graft_source is None:
Expand Down Expand Up @@ -1460,9 +1472,6 @@ def signVerify(self):
def signId(self):
return self._sign_id

def topic(self):
return None

def graft(self):
return None

Expand Down

0 comments on commit f6fcf31

Please sign in to comment.