Login

Update All Apps to Latest Revision

Author:
izibi
Posted:
July 18, 2008
Language:
Python
Version:
.96
Tags:
update svn git hg bzr
Score:
3 (after 3 ratings)

This snippet is based on #844 and updates all apps in the current directory using hg, svn, git or bzr.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#!/usr/env/python
import os
import os.path
from subprocess import call

if __name__ == "__main__":
    apps_dir = os.path.abspath('.')
    for app_name in os.listdir(apps_dir):
        app_dir = os.path.abspath(os.path.join(apps_dir, app_name))
        git_path = os.path.join(app_dir, '.git')
        svn_path = os.path.join(app_dir, '.svn')
        hg_path = os.path.join(app_dir, '.hg')
        bzr_path = os.path.join(app_dir, '.bzr')
        if os.path.lexists(svn_path):
            print "Updating svn %s" % app_dir
            os.chdir(app_dir)
            call(['svn', 'update'])
        elif os.path.lexists(git_path):
            print "Updating git %s" % app_dir
            os.chdir(app_dir)
            call(['git', 'pull'])
        elif os.path.lexists(hg_path):
            print "Updating hg %s" % app_dir
            os.chdir(app_dir)
            call(['hg', 'pull', '-u'])
        if os.path.lexists(bzr_path):
            print "Updating bzr %s" % app_dir
            os.chdir(app_dir)
            call(['bzr', 'update'])
        else:
            continue

More like this

  1. Update All Apps to Latest Revision by ericflo 6 years, 10 months ago
  2. Update All Apps to Latest Revision by dedaluz 6 years, 9 months ago
  3. update-django: Update your django git branches. by telenieko 6 years, 6 months ago
  4. Update applications by alem0lars 4 years, 10 months ago
  5. All Imports Checker by madhav.bnk 5 years, 5 months ago

Comments

ericflo (on July 18, 2008):

Cool! It would be nice if it detected if you had each VCS on your system, too. I wonder if that's easy.

#

dedaluz (on July 30, 2008):

What about searching for apps in subdirs? Let's say I have:

/home/python/lib/

with some apps, and

/home/python/lib/django-apps/

with apps related to Django. And I want to update all my apps under my lib dir.

#

izibi (on August 5, 2008):

@dedaluz The script uses the current path (.) so you can do something like this:

cd /home/python/lib
python /path/to/update.py

Or do I misunderstand your problem?

#

Please login first before commenting.