summaryrefslogtreecommitdiff
path: root/tools/patman
diff options
context:
space:
mode:
authorSimon Glass <sjg@chromium.org>2015-01-29 11:35:17 -0700
committerSimon Glass <sjg@chromium.org>2015-02-15 14:34:06 -0700
commit8895b3e16c7a2aab4275d52be19e485605dc5c7b (patch)
treed3d41d32802c8e2e27d532553c5babca1ea0e93d /tools/patman
parent71edbe5cdaf1516f070cf6c0910910b3240b0bf5 (diff)
downloadu-boot-8895b3e16c7a2aab4275d52be19e485605dc5c7b.tar.gz
u-boot-8895b3e16c7a2aab4275d52be19e485605dc5c7b.tar.bz2
u-boot-8895b3e16c7a2aab4275d52be19e485605dc5c7b.zip
patman: Read in the git-mailrc alias file
We should read this file to obtain a set of aliases. This reduces the need to create them in the ~/.patman file. This feature did exist in some version of patman, and is mentioned in the help but it did not find its way upstream. Reported-by: Graeme Russ <gruss@tss-engineering.com> Signed-off-by: Simon Glass <sjg@chromium.org>
Diffstat (limited to 'tools/patman')
-rw-r--r--tools/patman/settings.py27
1 files changed, 27 insertions, 0 deletions
diff --git a/tools/patman/settings.py b/tools/patman/settings.py
index 122e8fd981..ba2a68ff63 100644
--- a/tools/patman/settings.py
+++ b/tools/patman/settings.py
@@ -235,6 +235,31 @@ def _UpdateDefaults(parser, config):
else:
print "WARNING: Unknown setting %s" % name
+def _ReadAliasFile(fname):
+ """Read in the U-Boot git alias file if it exists.
+
+ Args:
+ fname: Filename to read.
+ """
+ if os.path.exists(fname):
+ bad_line = None
+ with open(fname) as fd:
+ linenum = 0
+ for line in fd:
+ linenum += 1
+ line = line.strip()
+ if not line or line.startswith('#'):
+ continue
+ words = line.split(' ', 2)
+ if len(words) < 3 or words[0] != 'alias':
+ if not bad_line:
+ bad_line = "%s:%d:Invalid line '%s'" % (fname, linenum,
+ line)
+ continue
+ alias[words[1]] = [s.strip() for s in words[2].split(',')]
+ if bad_line:
+ print bad_line
+
def Setup(parser, project_name, config_fname=''):
"""Set up the settings module by reading config files.
@@ -244,6 +269,8 @@ def Setup(parser, project_name, config_fname=''):
for sections named "project_section" as well.
config_fname: Config filename to read ('' for default)
"""
+ # First read the git alias file if available
+ _ReadAliasFile('doc/git-mailrc')
config = _ProjectConfigParser(project_name)
if config_fname == '':
config_fname = '%s/.patman' % os.getenv('HOME')