Update All Apps to Latest Revision

 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
32
33
34
35
36
37
38
#!/usr/env/python
import os
import os.path
from subprocess import call
    
def update(apps_dir):
    """Updates a collection of Subversion/Git/Mercurial/Bazaar working copies, including subdirectories"""
    for app_name in os.listdir(apps_dir):
        app_dir = os.path.abspath(os.path.join(apps_dir, app_name))
        if os.path.isdir(app_dir):
            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'])
            elif os.path.lexists(bzr_path):
                print "Updating bzr %s" % app_dir
                os.chdir(app_dir)
                call(['bzr', 'update'])     
            else:
                update(app_dir)
        else:
            continue
    return None
    
if __name__ == "__main__":
    update(os.path.abspath('.'))

More like this

  1. Update All Apps to Latest Revision by ericflo 5 years, 9 months ago
  2. update-django: Update your django git branches. by telenieko 5 years, 5 months ago
  3. Update All Apps to Latest Revision by izibi 5 years, 9 months ago
  4. set_paths by amitu 5 years, 6 months ago
  5. Full Model History by willhardy 5 years, 4 months ago

Comments

dedaluz (on July 30, 2008):

I think it could be useful to make it accept parameters like:

update_apps ..
update apps ./some-dir/

#

(Forgotten your password?)