Re: [U-Boot] [PATCH 3/4] patman: Add the concept of multiple projects

2012-12-03 Thread Simon Glass
Hi Doug,

On Fri, Nov 30, 2012 at 4:29 PM, Doug Anderson diand...@chromium.org wrote:
 There are cases that we want to support different settings (or maybe
 even different aliases) for different projects.  Add support for this
 by:
 * Adding detection for two big projects: U-Boot and Linux.
 * Adding default settings for Linux (U-Boot is already good with the
   standard patman defaults).
 * Extend the new settings feature in .patman to specify per-project
   settings.

 Signed-off-by: Doug Anderson diand...@chromium.org
 ---
  tools/patman/README  |   13 
  tools/patman/patman.py   |9 +++-
  tools/patman/project.py  |   43 +
  tools/patman/settings.py |  147 
 +-
  4 files changed, 208 insertions(+), 4 deletions(-)
  create mode 100644 tools/patman/project.py

 diff --git a/tools/patman/README b/tools/patman/README
 index 6ca5b5b..d294f3d 100644
 --- a/tools/patman/README
 +++ b/tools/patman/README
 @@ -114,6 +114,19 @@ verbose: True
  


 +If you want to adjust settings (or aliases) that affect just a single
 +project you can add a section that looks like [project_settings] or
 +[project_alias].  If you want to use tags for your linux work, you could
 +do:
 +
 +
 +
 +[linux_settings]
 +process_tags: True
 +
 +
 +
 +
  How to run it
  =

 diff --git a/tools/patman/patman.py b/tools/patman/patman.py
 index b327c67..54a252e 100755
 --- a/tools/patman/patman.py
 +++ b/tools/patman/patman.py
 @@ -34,6 +34,7 @@ import checkpatch
  import command
  import gitutil
  import patchstream
 +import project
  import settings
  import terminal
  import test
 @@ -59,6 +60,9 @@ parser.add_option('--cc-cmd', dest='cc_cmd', type='string', 
 action='store',
 default=None, help='Output cc list for patch file (used by git)')
  parser.add_option('--no-tags', action='store_false', dest='process_tags',
default=True, help=Don't process subject tags as aliaes)
 +parser.add_option('--project', default=project.DetectProject(),
 +  help=Project name; affects default option values and 
 +  aliases [default: %default])

Can you please add a short option also - perhaps -p?

[snip]

Regards,
Simon
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] [PATCH 3/4] patman: Add the concept of multiple projects

2012-12-03 Thread Doug Anderson
Simon,

Thanks!

On Mon, Dec 3, 2012 at 3:04 PM, Simon Glass s...@chromium.org wrote:
 Hi Doug,

 On Fri, Nov 30, 2012 at 4:29 PM, Doug Anderson diand...@chromium.org wrote:
 There are cases that we want to support different settings (or maybe
 even different aliases) for different projects.  Add support for this
 by:
 * Adding detection for two big projects: U-Boot and Linux.
 * Adding default settings for Linux (U-Boot is already good with the
   standard patman defaults).
 * Extend the new settings feature in .patman to specify per-project
   settings.

 Signed-off-by: Doug Anderson diand...@chromium.org
 ---
  tools/patman/README  |   13 
  tools/patman/patman.py   |9 +++-
  tools/patman/project.py  |   43 +
  tools/patman/settings.py |  147 
 +-
  4 files changed, 208 insertions(+), 4 deletions(-)
  create mode 100644 tools/patman/project.py

 diff --git a/tools/patman/README b/tools/patman/README
 index 6ca5b5b..d294f3d 100644
 --- a/tools/patman/README
 +++ b/tools/patman/README
 @@ -114,6 +114,19 @@ verbose: True
  


 +If you want to adjust settings (or aliases) that affect just a single
 +project you can add a section that looks like [project_settings] or
 +[project_alias].  If you want to use tags for your linux work, you could
 +do:
 +
 +
 +
 +[linux_settings]
 +process_tags: True
 +
 +
 +
 +
  How to run it
  =

 diff --git a/tools/patman/patman.py b/tools/patman/patman.py
 index b327c67..54a252e 100755
 --- a/tools/patman/patman.py
 +++ b/tools/patman/patman.py
 @@ -34,6 +34,7 @@ import checkpatch
  import command
  import gitutil
  import patchstream
 +import project
  import settings
  import terminal
  import test
 @@ -59,6 +60,9 @@ parser.add_option('--cc-cmd', dest='cc_cmd', 
 type='string', action='store',
 default=None, help='Output cc list for patch file (used by git)')
  parser.add_option('--no-tags', action='store_false', dest='process_tags',
default=True, help=Don't process subject tags as aliaes)
 +parser.add_option('--project', default=project.DetectProject(),
 +  help=Project name; affects default option values and 
 +  aliases [default: %default])

 Can you please add a short option also - perhaps -p?

Done.

 [snip]

 Regards,
 Simon
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] [PATCH 3/4] patman: Add the concept of multiple projects

2012-11-30 Thread Doug Anderson
There are cases that we want to support different settings (or maybe
even different aliases) for different projects.  Add support for this
by:
* Adding detection for two big projects: U-Boot and Linux.
* Adding default settings for Linux (U-Boot is already good with the
  standard patman defaults).
* Extend the new settings feature in .patman to specify per-project
  settings.

Signed-off-by: Doug Anderson diand...@chromium.org
---
 tools/patman/README  |   13 
 tools/patman/patman.py   |9 +++-
 tools/patman/project.py  |   43 +
 tools/patman/settings.py |  147 +-
 4 files changed, 208 insertions(+), 4 deletions(-)
 create mode 100644 tools/patman/project.py

diff --git a/tools/patman/README b/tools/patman/README
index 6ca5b5b..d294f3d 100644
--- a/tools/patman/README
+++ b/tools/patman/README
@@ -114,6 +114,19 @@ verbose: True
 
 
 
+If you want to adjust settings (or aliases) that affect just a single
+project you can add a section that looks like [project_settings] or
+[project_alias].  If you want to use tags for your linux work, you could
+do:
+
+
+
+[linux_settings]
+process_tags: True
+
+
+
+
 How to run it
 =
 
diff --git a/tools/patman/patman.py b/tools/patman/patman.py
index b327c67..54a252e 100755
--- a/tools/patman/patman.py
+++ b/tools/patman/patman.py
@@ -34,6 +34,7 @@ import checkpatch
 import command
 import gitutil
 import patchstream
+import project
 import settings
 import terminal
 import test
@@ -59,6 +60,9 @@ parser.add_option('--cc-cmd', dest='cc_cmd', type='string', 
action='store',
default=None, help='Output cc list for patch file (used by git)')
 parser.add_option('--no-tags', action='store_false', dest='process_tags',
   default=True, help=Don't process subject tags as aliaes)
+parser.add_option('--project', default=project.DetectProject(),
+  help=Project name; affects default option values and 
+  aliases [default: %default])
 
 parser.usage = patman [options]
 
@@ -66,7 +70,10 @@ Create patches from commits in a branch, check them and 
email them as
 specified by tags you place in the commits. Use -n to 
 
 
-settings.Setup(parser, '')
+# Parse options twice: first to get the project and second to handle
+# defaults properly (which depends on project).
+(options, args) = parser.parse_args()
+settings.Setup(parser, options.project, '')
 (options, args) = parser.parse_args()
 
 # Run our meagre tests
diff --git a/tools/patman/project.py b/tools/patman/project.py
new file mode 100644
index 000..4f7b2b3
--- /dev/null
+++ b/tools/patman/project.py
@@ -0,0 +1,43 @@
+# Copyright (c) 2012 The Chromium OS Authors.
+#
+# See file CREDITS for list of people who contributed to this
+# project.
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License as
+# published by the Free Software Foundation; either version 2 of
+# the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+# MA 02111-1307 USA
+#
+
+import os.path
+
+import gitutil
+
+def DetectProject():
+Autodetect the name of the current project.
+
+This looks for signature files/directories that are unlikely to exist 
except
+in the given project.
+
+Returns:
+The name of the project, like linux or u-boot.  Returns unknown
+if we can't detect the project.
+
+top_level = gitutil.GetTopLevel()
+
+if os.path.exists(os.path.join(top_level, include, u-boot)):
+return u-boot
+elif os.path.exists(os.path.join(top_level, kernel)):
+return linux
+
+return unknown
diff --git a/tools/patman/settings.py b/tools/patman/settings.py
index 5208f7d..084d1b8 100644
--- a/tools/patman/settings.py
+++ b/tools/patman/settings.py
@@ -26,6 +26,140 @@ import re
 import command
 import gitutil
 
+Default settings per-project.
+
+These are used by _ProjectConfigParser.  Settings names should match
+the dest of the option parser from patman.py.
+
+_default_settings = {
+u-boot: {},
+linux: {
+process_tags: False,
+}
+}
+
+class _ProjectConfigParser(ConfigParser.SafeConfigParser):
+ConfigParser that handles projects.
+
+There are two main goals of this class:
+- Load project-specific default settings.
+- Merge general default settings/aliases with project-specific ones.
+
+# Sample config used for tests below...
+ import StringIO
+ sample_config = '''
+... [alias]
+... me: Peter P.