Skip to main content

Dealer -- SCM (Git, Mercurial) watcher

Project description

Author: Kirill Klenov <>
License: BSD
Description: |logo| Dealer

.. _description:

Dealer — SCM_ revision helper in your projects. Just add SCM_ revision to
your static paths and get automatic control at client browser caches:

Somewhere in templates: ::

<script src='/main.js?{{ request.revision }}'

On clientside: ::

<script src='/main.js?34jhfd45hd8'

Supported Git_, Mercurial_ and simple revision parse by file.

.. note:: You should install Mercurial_ for hg support.

.. note:: For Django<2 please use Dealer<3

.. _badges:

.. image::
:alt: Build Status

.. image::
:alt: Coverals

.. image::
:alt: Version

.. image::
:alt: Downloads

.. image::
:alt: Donate

.. _contents:

.. contents::

.. _requirements:


- python 2.7, 3.5+

.. note:: For Django<2 please use Dealer<3

.. _installation:


**Dealer** should be installed using pip: ::

pip install dealer

.. _usage:


Basic usage

from dealer.git import git

print git.revision

print git.tag


# Auto parse repository type
from import auto
print auto.revision

print auto.tag

Manually create backend

**path** — path to SCM_ repository (current dir by default)

from dealer.mercurial import Backend

hg = Backend('/path/to/hg/repo')

Django support


**DEALER_TYPE** — Type of SCM_ repository ('auto', 'git', 'mercurial', 'simple', 'env', 'null'). By default 'auto';

**DEALER_PATH** — Path to SCM_. By default current dir;

**DEALER_SILENT** — Disable log warnings;

**DEALER_BACKENDS** — Backends for auto search by default ('git', 'mercurial', 'simple', 'env', 'null');


Append to your context processors: ::

context_processors = ['dealer.contrib.django.context_processor']

And use the *REVISION* and *TAG* variables in your templates: ::

<link href="/test.css?{{ REVISION }}" rel="stylesheet" type="text/css" media="screen" />
<script src="/test.js?{{ REVISION }}"></script>


Append to your settings: ::

MIDDLEWARE = ['dealer.contrib.django.Middleware']

And use in your views: ::

def view(request):
return request.revision

Or in your templates by `request.revision` var.

Flask support


*DEALER_TYPE* — Type of SCM_ repository ('auto', 'git', 'mercurial', 'simple', 'env', 'null'). By default 'auto'
*DEALER_PARAMS* — Params for backend


In views::

from flask import Flask, g
from dealer.contrib.flask import Dealer

app = Flask('test')
assert app.revision

def usage_in_view():
return g.revision

In templates: ::

<link href="/test.css?{{ REVISION }}" rel="stylesheet" type="text/css" media="screen" />

Pyramid support




def myview(request):
revision =
tag =

In templates



Heroku support


*DEALER_TYPE* = 'env'
*revision_env_keyname* - Variable name for revision (default: DEALER_REVISION)
*tag_env_keyname* - Variable name for tag (default: DEALER_TAG)


Setup your revision and tag value in envirement variables.
For example in
heroku config:set DEALER_REVISION='3ffb6b6'
heroku config:set DEALER_TAG=v1_1

After that use dealer as described above.

.. _bagtracker:

Bug tracker

If you have any suggestions, bug reports or
annoyances please report them to the issue tracker

.. _contributing:


Development of dealer happens at github:

.. _contributors:


* klen_ (Kirill Klenov)

.. _license:


Licensed under a `BSD license`_.

.. _links:

.. _BSD license:
.. _klen:
.. _SCM:
.. _Git:
.. _Mercurial:
.. |logo| image::
:width: 100

Keywords: mercurial,git,static,revision,django,flask
Platform: Any
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: Intended Audience :: System Administrators
Classifier: Natural Language :: Russian
Classifier: Natural Language :: English
Classifier: License :: OSI Approved :: BSD License
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python
Classifier: Programming Language :: Python :: 3.5
Classifier: Environment :: Console

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for dealer, version 2.1.0
Filename, size File type Python version Upload date Hashes
Filename, size dealer-2.1.0-py2.py3-none-any.whl (12.0 kB) File type Wheel Python version py2.py3 Upload date Hashes View hashes
Filename, size dealer-2.1.0.tar.gz (10.4 kB) File type Source Python version None Upload date Hashes View hashes

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page