{ "info": { "author": "Gerard Flanagan", "author_email": "grflanagan@gmail.com", "bugtrack_url": null, "classifiers": [], "description": "gravy.py\n########\n\nhg/hg-git command-line abstraction\n\ndevelopment\n-----------\n\nhttps://github.com/worrp/python-gravy\n\n\nUsage\n#####\n\nmercurial\n---------\n\n >>> import os\n >>> from gravy import HgRepo\n >>> repo = HgRepo.from_bitbucket('jespern', 'django-piston')\n >>> repo\n HgRepo (django-piston)\n >>> repo.url\n 'ssh://hg@bitbucket.org/jespern/django-piston'\n >>> repo.relpath\n 'bitbucket.org/jespern/django-piston'\n\n\nRepo objects are essentially a facade over a locally-cached repository.\n\n >>> repo.clone()\n >>> assert os.path.exists(repo.path)\n\nMethods/properties on the repo object match the options of the command line clients::\n\n >>> repo.branches\n [('default', '278:c4b2d21db51a')]\n >>> for tag in sorted(repo.tags):\n ... print tag\n ...\n ('0.1', '50:30c2c6b3a055')\n ('0.2.1', '117:a14b7b6ffa03')\n ('0.2.2', '152:6b0364d98837')\n ('tip', '278:c4b2d21db51a')\n\n\ngit\n---\n\ngithub.com::\n\n >>> repo = HgRepo.from_github('schacon', 'grit')\n >>> repo.url\n 'git+ssh://git@github.com/schacon/grit.git'\n >>> repo.clone()\n >>> repo.branches\n [('default', '340:e7cd96ec39e0')]\n >>> for tag in sorted(repo.tags):\n ... print tag\n ...\n ('gh-pages', '199:52074d70dd2e')\n ('integration', '198:172cd2460f15')\n ('master', '340:e7cd96ec39e0')\n ('tip', '340:e7cd96ec39e0')\n ('v0.7.0', '43:edce718a3bec')\n\ngitorious.org::\n\n >>> repo = HgRepo.from_gitorious('zedshaw', 'python-modargs')\n >>> repo.clone()\n >>> repo.branches\n [('default', '12:ec088657941a')]\n >>> for tag in sorted(repo.tags):\n ... print tag\n ...\n ('master', '12:ec088657941a')\n ('tip', '12:ec088657941a')\n\n >>> repo.checkout('master')\n >>> for f in sorted(repo.listdir()):\n ... print f\n ...\n .gitignore\n .hg\n LICENSE\n README.md\n docs\n examples\n modargs\n setup.py\n tests\n\ncheckout\n--------\n\n >>> repo = HgRepo.from_github('schacon', 'grit')\n >>> repo.checkout('master')\n >>> assert 'README.md' in repo.listdir()\n >>> assert not 'README.txt' in repo.listdir()\n >>> assert 'submodule.rb' in repo.listdir('lib/grit')\n\n >>> repo.checkout('integration')\n >>> assert not 'README.md' in repo.listdir()\n >>> assert 'README.txt' in repo.listdir()\n >>> assert not 'submodule.rb' in repo.listdir('lib/grit')\n\n >>> repo.checkout('derpdederp')\n Traceback (most recent call last):\n ...\n RuntimeError: Command hg update -C derpdederp failed with error code 255\n\n\ncopy\n----\n\n >>> repo = HgRepo.from_github('schacon', 'grit')\n >>> repo.checkout('master')\n >>> other = repo.copy()\n >>> assert other.path.startswith('/tmp/gravy-grit.git-')\n >>> assert other.listdir()\n >>> assert '.hg' in other.listdir()\n >>> assert other.listdir('.hg')\n >>> other.flush()\n\ncopyfiles\n---------\n\nCopy files only, not the VCS folders (.hg, .git, .bzr, .svn)::\n\n >>> import tempfile\n >>> tmp = tempfile.mkdtemp(prefix='gravy-TEST-') + '/TEST/'\n >>> assert tmp.startswith('/tmp/gravy-TEST-')\n >>> assert not os.path.exists(tmp)\n >>> repo.copyfiles(tmp)\n >>> assert os.path.exists(tmp)\n >>> assert os.listdir(tmp)\n >>> assert '.hg' not in os.listdir(tmp)\n\nanyrepo\n-------\n\n >>> from gravy import anyrepo\n\n >>> repo = anyrepo('github', 'facebook', 'tornado')\n >>> assert isinstance(repo, HgRepo)\n >>> repo.url\n 'git+ssh://git@github.com/facebook/tornado.git'\n >>> repo.clone()\n\n >>> repo = anyrepo('bitbucket', 'birkenfeld', 'sphinx')\n >>> assert isinstance(repo, HgRepo)\n >>> repo.url\n 'ssh://hg@bitbucket.org/birkenfeld/sphinx'\n >>> repo.clone()\n\n >>> repo = anyrepo('git://gitorious.org/python-modargs/python-modargs.git')\n >>> assert isinstance(repo, HgRepo)\n >>> repo.url\n 'git://gitorious.org/python-modargs/python-modargs.git'\n >>> repo.relpath\n 'gitorious.org/python-modargs/python-modargs.git'\n >>> repo.clone()\n\n >>> repo = anyrepo('gitorious', 'zedshaw', 'learn-python-the-hard-way')\n >>> assert isinstance(repo, HgRepo)\n >>> repo.url\n 'git://gitorious.org/~zedshaw/learn-python-the-hard-way/learn-python-the-hard-way.git'\n >>> repo.relpath\n 'gitorious.org/zedshaw/learn-python-the-hard-way/learn-python-the-hard-way.git'\n >>> repo.clone()\n\nurlsplit\n--------\n\n >>> from gravy import urlsplit\n >>> urlsplit('https://bitbucket.org/birkenfeld/sphinx')\n ('hg', 'https', 'bitbucket.org', 'birkenfeld', 'sphinx', '')\n >>> urlsplit('http://bitbucket.org/birkenfeld/sphinx')\n ('hg', 'http', 'bitbucket.org', 'birkenfeld', 'sphinx', '')\n >>> urlsplit('ssh://hg@bitbucket.org/birkenfeld/sphinx')\n ('hg', 'ssh', 'bitbucket.org', 'birkenfeld', 'sphinx', '')\n >>> urlsplit('https://gitorious.org/python-modargs/python-modargs.git')\n ('git', 'https', 'gitorious.org', '', 'python-modargs', 'python-modargs.git')\n >>> urlsplit('https://gitorious.org/~zedshaw/python-modargs/python-modargs.git')\n ('git', 'https', 'gitorious.org', 'zedshaw', 'python-modargs', 'python-modargs.git')\n >>> urlsplit('git://gitorious.org/~zedshaw/python-modargs/python-modargs.git')\n ('git', 'git', 'gitorious.org', 'zedshaw', 'python-modargs', 'python-modargs.git')\n >>> urlsplit('git://mydomain.org/myproject/myproject.git')\n ('git', 'git', 'mydomain.org', '', 'myproject', 'myproject.git')\n >>> urlsplit('http://git.mydomain.org/myproject/myproject.git')\n ('git', 'http', 'git.mydomain.org', '', 'myproject', 'myproject.git')\n >>> urlsplit('')\n ('hg', 'https', '', '', '', '')\n >>> urlsplit('http://hg.python.org/cpython')\n ('hg', 'http', 'hg.python.org', '', '', 'cpython')\n >>> urlsplit('ssh://git@github.com/facebook/tornado.git')\n ('git', 'ssh', 'github.com', 'facebook', 'tornado', '')\n\nincoming, outgoing, commit, pull\n--------------------------------\n\nCreate and clone::\n\n >>> repo = anyrepo('github', 'pypa', 'pip')\n >>> repo.clone()\n >>> assert not repo.incoming()\n >>> assert not repo.outgoing()\n\nCommit with no changes is a no-op::\n\n >>> repo.commit('abcdef')\n\nCreate a copy and make changes to it::\n\n >>> copy = repo.copy()\n >>> assert not copy.outgoing()\n >>> fname = copy.pathto('pip/__init__.py')\n >>> with open(fname, 'w+b') as fp:\n ... fp.write('GRAVY TEST')\n ...\n >>> assert os.path.exists(copy.pathto('pip/locations.py'))\n >>> copy.remove('pip/locations.py')\n >>> copy.commit('Testing update')\n >>> assert not os.path.exists(copy.pathto('pip/locations.py'))\n >>> assert open(copy.pathto('pip/__init__.py')).read() == 'GRAVY TEST'\n\nOutgoing of copy with respect to the original repo::\n\n >>> assert copy.outgoing(dest=repo.path)\n\nIncoming of original with respect to the changed copy::\n\n >>> repo.flush_incoming()\n >>> assert not os.listdir(repo._incoming)\n >>> assert repo.incoming(source=copy.path)\n\nThe call to incoming created a bundle file::\n\n >>> assert len(os.listdir(repo._incoming)) == 1\n\nRollback the changes to the copy to help confirm the next pull uses the stored bundle::\n\n >>> copy.rollback()\n >>> copy.revertall()\n >>> assert os.path.exists(copy.pathto('pip/locations.py'))\n >>> assert not open(copy.pathto('pip/__init__.py')).read() == 'GRAVY TEST'\n\nNow pull::\n\n >>> assert os.path.exists(repo.pathto('pip/locations.py'))\n >>> assert not open(repo.pathto('pip/__init__.py')).read() == 'GRAVY TEST'\n >>> repo.pull(source=copy.path, update=True)\n >>> assert not os.path.exists(repo.pathto('pip/locations.py'))\n >>> assert open(repo.pathto('pip/__init__.py')).read() == 'GRAVY TEST'\n >>> repo.rollback()\n >>> repo.revertall()\n >>> assert os.path.exists(repo.pathto('pip/locations.py'))\n >>> assert not open(repo.pathto('pip/__init__.py')).read() == 'GRAVY TEST'\n\nbranch\n------\n\nCurrent branch name::\n\n >>> sorted(copy.branchmap().keys())\n ['default']\n >>> copy.branch()\n 'default'\n >>> sorted(copy.branchmap().keys())\n ['default']\n\nCreate a new branch::\n\n >>> copy.branch('testing')\n >>> sorted(copy.branchmap().keys())\n ['default']\n >>> copy.branch()\n 'testing'\n\nMake changes::\n\n >>> assert os.path.exists(copy.pathto('pip/locations.py'))\n >>> copy.remove('pip/locations.py')\n >>> copy.commit('new branch')\n >>> sorted(copy.branchmap().keys())\n ['default', 'testing']\n >>> assert not os.path.exists(copy.pathto('pip/locations.py'))\n >>> copy.checkout('default')\n >>> assert os.path.exists(copy.pathto('pip/locations.py'))\n\n\nFind python packages and modules\n################################\n\n >>> pyfiles = repo.find_py_files()\n >>> sorted(pyfiles['packages'])\n [('pip', 'pip')]\n >>> sorted(pyfiles['modules'])\n [('get-pip', 'contrib/get-pip.py')]\n\n >>> repo = HgRepo.from_github('schacon', 'grit')\n >>> pyfiles = repo.find_py_files()\n >>> sorted(pyfiles['packages'])\n []\n >>> sorted(pyfiles['modules'])\n []\n\n >>> repo = HgRepo.from_bitbucket('jespern', 'django-piston')\n >>> pyfiles = repo.find_py_files()\n >>> sorted(pyfiles['packages'])\n [('piston', 'piston')]\n >>> sorted(pyfiles['modules'])\n []\n\n >>> repo = HgRepo.from_gitorious('zedshaw', 'python-modargs')\n >>> pyfiles = repo.find_py_files()\n >>> sorted(pyfiles['packages'])\n [('modargs', 'modargs')]\n >>> sorted(pyfiles['modules'])\n []\n\n >>> repo = anyrepo('gitorious', 'zedshaw', 'learn-python-the-hard-way')\n >>> pyfiles = repo.find_py_files()\n >>> for x in sorted(pyfiles['packages']):\n ... print x\n ...\n ('bin', 'ex/ex51/gothonweb/bin')\n ('gothonweb', 'ex/ex51/gothonweb/gothonweb')\n ('tests', 'ex/ex51/gothonweb/tests')\n >>> for x in sorted(pyfiles['modules']):\n ... print x #doctest: +ELLIPSIS\n ...\n ('app', 'ex/ex50/gothonweb/bin/app.py')\n ('conf', 'conf.py')\n ('conf_hard', 'conf_hard.py')\n ('conf_html', 'conf_html.py')\n ('conf_paper', 'conf_paper.py')\n ('ex', 'ex/ex.py')\n ('ex1', 'ex/ex1.py')\n ('ex10', 'ex/ex10.py')\n ('ex11', 'ex/ex11.py')\n ...\n\n >>> repo = HgRepo.from_github('worrp', 'python-dubbel')\n >>> repo.clone()\n >>> pyfiles = repo.find_py_files()\n >>> sorted(pyfiles['packages'])\n []\n >>> sorted(pyfiles['modules'])\n [('dubbel', 'dubbel.py')]\n\n >>> repo = HgRepo.from_github('facebook', 'tornado')\n >>> repo.clone()\n >>> pyfiles = repo.find_py_files()\n >>> sorted(pyfiles['packages'])\n [('tornado', 'tornado')]\n >>> for item in sorted(pyfiles['modules']):\n ... print item\n ...\n ('conf', 'website/sphinx/conf.py')\n ('sphinx_coverage', 'website/sphinx/sphinx_coverage.py')\n ('website', 'website/website.py')", "description_content_type": null, "docs_url": null, "download_url": "http://pypi.python.org/packages/source/g/gravy/gravy-0.2.2.tar.gz", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "UNKNOWN", "keywords": null, "license": "UNKNOWN", "maintainer": null, "maintainer_email": null, "name": "gravy", "package_url": "https://pypi.org/project/gravy/", "platform": "UNKNOWN", "project_url": "https://pypi.org/project/gravy/", "project_urls": { "Download": "http://pypi.python.org/packages/source/g/gravy/gravy-0.2.2.tar.gz", "Homepage": "UNKNOWN" }, "release_url": "https://pypi.org/project/gravy/0.2.2/", "requires_dist": null, "requires_python": null, "summary": "Simple VCS wrapper", "version": "0.2.2" }, "last_serial": 792680, "releases": { "0.2.2": [ { "comment_text": "", "digests": { "md5": "0e3f84209ba768fa8863a61edd677e9d", "sha256": "a4f0cccd28b9678b885d8280b4cea76e3a4982e6e0bb0c952faea850f4e9890d" }, "downloads": -1, "filename": "gravy-0.2.2.tar.gz", "has_sig": false, "md5_digest": "0e3f84209ba768fa8863a61edd677e9d", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 10671, "upload_time": "2011-09-02T11:12:00", "url": "https://files.pythonhosted.org/packages/c4/7d/363e6bba0d39efa151dc99e8d482becda121dae685bf3a114bc199895431/gravy-0.2.2.tar.gz" }, { "comment_text": "", "digests": { "md5": "21f84366829f243d8e96e9d6cfcf60f8", "sha256": "e07901e0bbbd5b6af5092e3ffb0ca7b9f8810e5e52469b5d1b9f8f97b01e4278" }, "downloads": -1, "filename": "gravy-0.2.2.zip", "has_sig": false, "md5_digest": "21f84366829f243d8e96e9d6cfcf60f8", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 12006, "upload_time": "2011-09-02T11:12:01", "url": "https://files.pythonhosted.org/packages/8d/10/050c1d43412e6896216545f0bfbb65806e94c4f6d541fe8eb0cc7baecfd0/gravy-0.2.2.zip" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "0e3f84209ba768fa8863a61edd677e9d", "sha256": "a4f0cccd28b9678b885d8280b4cea76e3a4982e6e0bb0c952faea850f4e9890d" }, "downloads": -1, "filename": "gravy-0.2.2.tar.gz", "has_sig": false, "md5_digest": "0e3f84209ba768fa8863a61edd677e9d", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 10671, "upload_time": "2011-09-02T11:12:00", "url": "https://files.pythonhosted.org/packages/c4/7d/363e6bba0d39efa151dc99e8d482becda121dae685bf3a114bc199895431/gravy-0.2.2.tar.gz" }, { "comment_text": "", "digests": { "md5": "21f84366829f243d8e96e9d6cfcf60f8", "sha256": "e07901e0bbbd5b6af5092e3ffb0ca7b9f8810e5e52469b5d1b9f8f97b01e4278" }, "downloads": -1, "filename": "gravy-0.2.2.zip", "has_sig": false, "md5_digest": "21f84366829f243d8e96e9d6cfcf60f8", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 12006, "upload_time": "2011-09-02T11:12:01", "url": "https://files.pythonhosted.org/packages/8d/10/050c1d43412e6896216545f0bfbb65806e94c4f6d541fe8eb0cc7baecfd0/gravy-0.2.2.zip" } ] }