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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@ upseto.egg-info
.coverage*
.venv
.idea
.eggs
2 changes: 2 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
pbr>=1.9
PyYAML==3.11
33 changes: 33 additions & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
[metadata]
name = upseto
author = Shlomo Matichin
author-email = shlomi@stratoscale.com
summary = Split your projects across git repos without the disatvantages of git submodule
description-file = README.md
home-page = https://github.com/stratoscale/upseto
license = TBD
classifier =
Development Status :: 4 - Beta
Environment :: Console
Environment :: Stratoscale
Intended Audience :: Developers
Intended Audience :: Information Technology
Operating System :: Linux
Programming Language :: Python
keywords =
git
repos
repositories
python
scm
[files]
packages =
upseto
data_files =
bin/bash_completion.d =
conf/bash_completion.d/upseto.sh
lib/python2.7/site-packages =
conf/upseto.pth
[entry_points]
console_scripts =
upseto = upseto.main:main
42 changes: 6 additions & 36 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,40 +1,10 @@
import os
from setuptools import setup

from distutils import sysconfig
site_packages_path = sysconfig.get_python_lib()

data_files = [(site_packages_path, ["conf/upseto.pth"])]

# add in case we are running as root
if os.geteuid() == 0:
data_files += [
('/etc/bash_completion.d', ['conf/bash_completion.d/upseto.sh']),
]
#!/usr/bin/env python


def read(fname):
return open(os.path.join(os.path.dirname(__file__), fname)).read()
from setuptools import setup

setup(
name="upseto",
version="1.1",
author="Shlomo Matichin",
author_email="shlomi@stratoscale.com",
description=(
"Split your projects across git repos without the disatvantages"
" of git submodule"),
keywords="git repos repositories python scm",
url="http://packages.python.org/upseto",
packages=['upseto'],
long_description=read('README.md'),
classifiers=[
"Development Status :: 4 - Beta",
"Topic :: Utilities",
],
install_requires=[
"PyYAML==3.11"
],
data_files=data_files,
scripts=['sh/upseto'],
setup_requires=['pbr>=1.9', 'setuptools>=17.1'],
pbr=True,
)


2 changes: 0 additions & 2 deletions sh/upseto

This file was deleted.

202 changes: 104 additions & 98 deletions upseto/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,104 +10,110 @@

logging.basicConfig(level=logging.INFO)

commandLine = sys.argv[1:]
gitArgs = []
if 'git' in commandLine:
gitArgs = commandLine[commandLine.index('git') + 1:]
commandLine = commandLine[:commandLine.index('git') + 1]
parser = argparse.ArgumentParser()
subparsers = parser.add_subparsers(dest="cmd")
addRequirement = subparsers.add_parser(
"addRequirement",
help="Name of the directory of the project, in the parent directory."
" The current HEAD revision will be used as the requirement hash")
addRequirement.add_argument("project", nargs="+")
addRequirement.add_argument(
"--dirtyParadoxResolution", nargs='+', default=[],
help="space sparated list of project basenames (not a single argument). "
"If a project has two different hashes in the recursive requirement "
"tree, force the hash from the current manifest. Projects that add this "
"to their manifests become inheritnly dirty, and even project that will "
"use this hash later on. All these flags will be cleared on the next "
"'addRequirement', unless it is repeated (even when adding different "
"projects)")
delRequirement = subparsers.add_parser(
"delRequirement",
help="Remove a requirement from the manifest file, by project name")
delRequirement.add_argument("project")
fulfillRequirements = subparsers.add_parser(
"fulfillRequirements",
help="Checkout the exact versions of all requirements, recursively."
" Note that if you have patches this depends on the behavior "
"of git checkout in the apropriate cases, including possible "
"failures")
checkRequirements = subparsers.add_parser(
"checkRequirements",
help="Check that the HEAD revision of all dependencies, recursivly, "
"matches the recursive requirements. Note that this does not "
"check dirtyness of the working directories.")
checkRequirements.add_argument(
"--show", action="store_true",
help="show all the dependencies, recursively")
checkRequirements.add_argument(
"--gitClean", action="store_true",
help="fail if not all dependencies are 'git status' clean")
checkRequirements.add_argument(
"--unsullied", action="store_true",
help="fail if workspace contains other files not under "
"upseto recursive dependency tree")
checkRequirements.add_argument(
"--allowNoManifest", action="store_true",
help="if this project does not contain an upseto.manifest file "
"consider as if it has an empty one. Allows checking gitClean "
"and unsullied uniformly in projects")
git = subparsers.add_parser(
"git",
help="Run a git command recursively on all dependencies. E.g., "
"'upseto git status -s' will show status of all dependant "
"projects")
args = parser.parse_args(commandLine)

baseDir = ".."
if args.cmd == "addRequirement":
mani = manifest.Manifest.fromLocalDirOrNew()
for project in args.project:
projectDirectory = os.path.join(baseDir, project)
git = gitwrapper.GitWrapper(projectDirectory)
mani.addRequirement(originURL=git.originURL(), hash=git.hash())
logging.info("Adding the origin URL '%(originURL)s' at hash '%(hash)s' as a requirement", dict(
originURL=git.originURL(), hash=git.hash()))
mani.clearAllDirtyParadoxResolution()
for dirtyParadoxResolution in args.dirtyParadoxResolution:
mani.setDirtyParadoxResolution(dirtyParadoxResolution)
check = checkfulfilled.CheckFulfilled(baseDir)
check.check(mani)
mani.save()
logging.info("Requirements successfully added")
elif args.cmd == "delRequirement":
mani = manifest.Manifest.fromLocalDir()
originURL = mani.delRequirementByBasename(args.project)
mani.save()
logging.info("Removed the origin URL '%s' from requirements", originURL)
elif args.cmd == "fulfillRequirements":
mani = manifest.Manifest.fromLocalDir()
ff = fulfiller.Fulfiller(mani, baseDir)
logging.info("Requirements Fulfilled")
elif args.cmd == "checkRequirements":
if args.allowNoManifest:
def main():
commandLine = sys.argv[1:]
gitArgs = []
if 'git' in commandLine:
gitArgs = commandLine[commandLine.index('git') + 1:]
commandLine = commandLine[:commandLine.index('git') + 1]
parser = argparse.ArgumentParser()
subparsers = parser.add_subparsers(dest="cmd")
addRequirement = subparsers.add_parser(
"addRequirement",
help="Name of the directory of the project, in the parent directory."
" The current HEAD revision will be used as the requirement hash")
addRequirement.add_argument("project", nargs="+")
addRequirement.add_argument(
"--dirtyParadoxResolution", nargs='+', default=[],
help="space sparated list of project basenames (not a single argument). "
"If a project has two different hashes in the recursive requirement "
"tree, force the hash from the current manifest. Projects that add this "
"to their manifests become inheritnly dirty, and even project that will "
"use this hash later on. All these flags will be cleared on the next "
"'addRequirement', unless it is repeated (even when adding different "
"projects)")
delRequirement = subparsers.add_parser(
"delRequirement",
help="Remove a requirement from the manifest file, by project name")
delRequirement.add_argument("project")
fulfillRequirements = subparsers.add_parser(
"fulfillRequirements",
help="Checkout the exact versions of all requirements, recursively."
" Note that if you have patches this depends on the behavior "
"of git checkout in the apropriate cases, including possible "
"failures")
checkRequirements = subparsers.add_parser(
"checkRequirements",
help="Check that the HEAD revision of all dependencies, recursivly, "
"matches the recursive requirements. Note that this does not "
"check dirtyness of the working directories.")
checkRequirements.add_argument(
"--show", action="store_true",
help="show all the dependencies, recursively")
checkRequirements.add_argument(
"--gitClean", action="store_true",
help="fail if not all dependencies are 'git status' clean")
checkRequirements.add_argument(
"--unsullied", action="store_true",
help="fail if workspace contains other files not under "
"upseto recursive dependency tree")
checkRequirements.add_argument(
"--allowNoManifest", action="store_true",
help="if this project does not contain an upseto.manifest file "
"consider as if it has an empty one. Allows checking gitClean "
"and unsullied uniformly in projects")
git = subparsers.add_parser(
"git",
help="Run a git command recursively on all dependencies. E.g., "
"'upseto git status -s' will show status of all dependant "
"projects")
args = parser.parse_args(commandLine)

baseDir = ".."
if args.cmd == "addRequirement":
mani = manifest.Manifest.fromLocalDirOrNew()
else:
for project in args.project:
projectDirectory = os.path.join(baseDir, project)
git = gitwrapper.GitWrapper(projectDirectory)
mani.addRequirement(originURL=git.originURL(), hash=git.hash())
logging.info("Adding the origin URL '%(originURL)s' at hash '%(hash)s' as a requirement", dict(
originURL=git.originURL(), hash=git.hash()))
mani.clearAllDirtyParadoxResolution()
for dirtyParadoxResolution in args.dirtyParadoxResolution:
mani.setDirtyParadoxResolution(dirtyParadoxResolution)
check = checkfulfilled.CheckFulfilled(baseDir)
check.check(mani)
mani.save()
logging.info("Requirements successfully added")
elif args.cmd == "delRequirement":
mani = manifest.Manifest.fromLocalDir()
originURL = mani.delRequirementByBasename(args.project)
mani.save()
logging.info("Removed the origin URL '%s' from requirements", originURL)
elif args.cmd == "fulfillRequirements":
mani = manifest.Manifest.fromLocalDir()
ff = fulfiller.Fulfiller(mani, baseDir)
logging.info("Requirements Fulfilled")
elif args.cmd == "checkRequirements":
if args.allowNoManifest:
mani = manifest.Manifest.fromLocalDirOrNew()
else:
mani = manifest.Manifest.fromLocalDir()
check = checkfulfilled.CheckFulfilled(baseDir, gitClean=args.gitClean)
check.check(mani)
if args.unsullied:
check.unsullied()
logging.info("Requirements Checked")
if args.show:
logging.info("\n%s", check.renderAsTreeText())
elif args.cmd == "git":
mani = manifest.Manifest.fromLocalDir()
check = checkfulfilled.CheckFulfilled(baseDir, gitClean=args.gitClean)
check.check(mani)
if args.unsullied:
check.unsullied()
logging.info("Requirements Checked")
if args.show:
logging.info("\n%s", check.renderAsTreeText())
elif args.cmd == "git":
mani = manifest.Manifest.fromLocalDir()
recursiveGit = recursivegit.RecursiveGit(baseDir)
recursiveGit.run(mani, gitArgs)
else:
assert False, "command mismatch"
recursiveGit = recursivegit.RecursiveGit(baseDir)
recursiveGit.run(mani, gitArgs)
else:
assert False, "command mismatch"


if __name__ == '__main__':
main()