Mercurial > hgweb.cgi > hwm
changeset 45:b3209e186415
The common group is added by default unless explicitly told to skip. IN: -
author | John Schneiderman <JohnMS@CodeGNU.com> |
---|---|
date | Thu, 21 Aug 2014 18:25:49 -0500 |
parents | b19cfcba5dfa |
children | e15f5cbaec00 |
files | src/hwm.py src/manager.py |
diffstat | 2 files changed, 22 insertions(+), 11 deletions(-) [+] |
line wrap: on
line diff
--- a/src/hwm.py Thu Aug 21 17:57:30 2014 -0500 +++ b/src/hwm.py Thu Aug 21 18:25:49 2014 -0500 @@ -102,6 +102,7 @@ manGrp.add_argument('storage', action='store', nargs='?', help='The storage-name of the repository to perform an action upon.') manGrp.add_argument('-a', '--action', action='store', nargs=1, type=str, choices=['c', 'create', 'm', 'modify', 'd', 'delete', 'r', 'register'], help='Performs an action upon a managed repository.') manGrp.add_argument('-i', '--ignore', action='store', nargs='+', default=None, help='The groups to place in an ignore file.') + manGrp.add_argument('-s', '--skip-common', action='store_true', help='The common ignore group is not added by default.') manGrp.add_argument('-n', '--name', action='store', nargs='?', default=None, help='The display name of the repository.') manGrp.add_argument('-d', '--description', action='store', nargs='?', default=None, help='The description of the repository.') manGrp.add_argument('-c', '--contact', action='store', nargs='?', default=None, help='The contact point of a repository.') @@ -118,14 +119,10 @@ print >>sys.stderr, "No actionable arguments supplied." exit(1) elif ('create' == args.action[0]) or ('c' == args.action[0]): - if args.ignore: - ignores = args.ignore - else: - ignores = ['Common'] - if not manager.create(repo, ignores): + if not manager.create(repo, args.ignore, args.skip_common): exit(2) elif ('modify' == args.action[0]) or ('m' == args.action[0]): - if not manager.modify(repo, args.storage, args.ignore): + if not manager.modify(repo, args.storage, args.ignore, args.skip_common): exit(2) elif ('delete' == args.action[0]) or ('d' == args.action[0]): if not manager.delete(repo):
--- a/src/manager.py Thu Aug 21 17:57:30 2014 -0500 +++ b/src/manager.py Thu Aug 21 18:25:49 2014 -0500 @@ -25,13 +25,15 @@ from hwm import settings -def create(repository, ignoreGroup): +def create(repository, ignoreGroup, skipCommon): """ Creates a new repository under HgWeb. @pre The repository to create cannot already exist. @param[in] repository The targeted repository to create. @param[in] ignoreGroup The list of all ignore groups to add. + @param[in] skipCommon A flag that when true indicates the common group + should not be added by default. @post The file system now contains a new directory in the repository path that is the newly generated repository. The new repository is registered @@ -60,7 +62,7 @@ # Create the requested repository. if __addRepository(repository): print "Initialised repository directory." - if not __create_ignores(repository, ignoreGroup): + if not __create_ignores(repository, ignoreGroup, skipCommon): __removeRepository(repository) return False else: @@ -115,7 +117,7 @@ print >>sys.stderr, "Failed to register repository." return False -def modify(newRepository, currentStorageName, ignoreGroup): +def modify(newRepository, currentStorageName, ignoreGroup, skipCommon): """ Changes an existing repository in HgWeb. @pre The repository to modify must already exist. @@ -125,6 +127,9 @@ @param[in] currentStorageName The current storage name of the repository to modify. @param[in] ignoreGroup The list of all ignore groups to add. + @param[in] skipCommon A flag that when true indicates the + common group should not be added by + default. @post The repository is changed with the requested modifications. @@ -180,7 +185,7 @@ # Update ignore file if requested. if ignoreGroup is not None: - if __create_ignores(newRepository, ignoreGroup): + if __create_ignores(newRepository, ignoreGroup, skipCommon): print "Successfully modified ignore file." else: print >>sys.stderr, "Failed to modify ignore file." @@ -254,7 +259,7 @@ -def __create_ignores(repo, ignoreGroup): +def __create_ignores(repo, ignoreGroup, skipCommon): """ Generates and commits an ignore file to an existing repository. @pre The repository to create an ignore file must already exist. The list @@ -263,6 +268,8 @@ @param[in] repo The targeted repository for the ignore file. @param[in] ignoreGroup The list of all ignore groups to add. + @param[in] skipCommon A flag that when true indicates the common group + should not be added by default. @post The managed repository now has an ignore file committed by the HgWeb manager. @@ -275,6 +282,8 @@ import xml # Extract Ignore Collection + if ignoreGroup is None: + ignoreGroup = [] ignores = {} try: ignores = ignorepo.extract('ignores.xml') @@ -285,6 +294,11 @@ print >>sys.stderr, "Failed to extract ignores, error: %s" % e.message return False + if skipCommon: + del ignores['Common'] + elif not 'common' in [ignoreName.lower() for ignoreName in ignoreGroup]: + ignoreGroup.append('Common') + ignoreFile = settings.RepositoryPath + os.sep + repo.StorageName + os.sep + '.hgignore' wasCreated = not os.path.isfile(ignoreFile) if wasCreated: