Mercurial > hg > silvermirror
annotate silvermirror/hg.py @ 2:0d9094bb98b0
adding function to return all hg repos on a path
author | k0s <k0scist@gmail.com> |
---|---|
date | Fri, 02 Oct 2009 19:00:46 -0400 |
parents | 9b139702a8f9 |
children | 8a5d2083fbd1 |
rev | line source |
---|---|
1
9b139702a8f9
use a real backend architecture with an inteface and vastly simplify unify.py
k0s <k0scist@gmail.com>
parents:
diff
changeset
|
1 #!/usr/bin/env python |
9b139702a8f9
use a real backend architecture with an inteface and vastly simplify unify.py
k0s <k0scist@gmail.com>
parents:
diff
changeset
|
2 """ |
9b139702a8f9
use a real backend architecture with an inteface and vastly simplify unify.py
k0s <k0scist@gmail.com>
parents:
diff
changeset
|
3 stub for the hg backend of silvermirror |
9b139702a8f9
use a real backend architecture with an inteface and vastly simplify unify.py
k0s <k0scist@gmail.com>
parents:
diff
changeset
|
4 """ |
9b139702a8f9
use a real backend architecture with an inteface and vastly simplify unify.py
k0s <k0scist@gmail.com>
parents:
diff
changeset
|
5 |
9b139702a8f9
use a real backend architecture with an inteface and vastly simplify unify.py
k0s <k0scist@gmail.com>
parents:
diff
changeset
|
6 import os |
9b139702a8f9
use a real backend architecture with an inteface and vastly simplify unify.py
k0s <k0scist@gmail.com>
parents:
diff
changeset
|
7 from mercurial import commands, hg, ui |
9b139702a8f9
use a real backend architecture with an inteface and vastly simplify unify.py
k0s <k0scist@gmail.com>
parents:
diff
changeset
|
8 |
9b139702a8f9
use a real backend architecture with an inteface and vastly simplify unify.py
k0s <k0scist@gmail.com>
parents:
diff
changeset
|
9 def update(host, path): |
9b139702a8f9
use a real backend architecture with an inteface and vastly simplify unify.py
k0s <k0scist@gmail.com>
parents:
diff
changeset
|
10 """ |
9b139702a8f9
use a real backend architecture with an inteface and vastly simplify unify.py
k0s <k0scist@gmail.com>
parents:
diff
changeset
|
11 get changes from host on path |
9b139702a8f9
use a real backend architecture with an inteface and vastly simplify unify.py
k0s <k0scist@gmail.com>
parents:
diff
changeset
|
12 """ |
9b139702a8f9
use a real backend architecture with an inteface and vastly simplify unify.py
k0s <k0scist@gmail.com>
parents:
diff
changeset
|
13 ui = ui.ui() |
9b139702a8f9
use a real backend architecture with an inteface and vastly simplify unify.py
k0s <k0scist@gmail.com>
parents:
diff
changeset
|
14 try: |
9b139702a8f9
use a real backend architecture with an inteface and vastly simplify unify.py
k0s <k0scist@gmail.com>
parents:
diff
changeset
|
15 repo = hg.repository(ui, path) |
9b139702a8f9
use a real backend architecture with an inteface and vastly simplify unify.py
k0s <k0scist@gmail.com>
parents:
diff
changeset
|
16 command = commands.pull |
9b139702a8f9
use a real backend architecture with an inteface and vastly simplify unify.py
k0s <k0scist@gmail.com>
parents:
diff
changeset
|
17 except mercurial.repo.RepoError: |
9b139702a8f9
use a real backend architecture with an inteface and vastly simplify unify.py
k0s <k0scist@gmail.com>
parents:
diff
changeset
|
18 repo = hg.repository(ui, 'ssh://%s/%s' % (host, path)) |
9b139702a8f9
use a real backend architecture with an inteface and vastly simplify unify.py
k0s <k0scist@gmail.com>
parents:
diff
changeset
|
19 command = commands.clone |
2
0d9094bb98b0
adding function to return all hg repos on a path
k0s <k0scist@gmail.com>
parents:
1
diff
changeset
|
20 |
0d9094bb98b0
adding function to return all hg repos on a path
k0s <k0scist@gmail.com>
parents:
1
diff
changeset
|
21 def repositories(path): |
0d9094bb98b0
adding function to return all hg repos on a path
k0s <k0scist@gmail.com>
parents:
1
diff
changeset
|
22 """ |
0d9094bb98b0
adding function to return all hg repos on a path
k0s <k0scist@gmail.com>
parents:
1
diff
changeset
|
23 return all hg repositories in a path |
0d9094bb98b0
adding function to return all hg repos on a path
k0s <k0scist@gmail.com>
parents:
1
diff
changeset
|
24 """ |
0d9094bb98b0
adding function to return all hg repos on a path
k0s <k0scist@gmail.com>
parents:
1
diff
changeset
|
25 |
0d9094bb98b0
adding function to return all hg repos on a path
k0s <k0scist@gmail.com>
parents:
1
diff
changeset
|
26 ui = ui.ui() |
0d9094bb98b0
adding function to return all hg repos on a path
k0s <k0scist@gmail.com>
parents:
1
diff
changeset
|
27 files = [ os.path.join(path, f) for f in os.listdir(path) ] |
0d9094bb98b0
adding function to return all hg repos on a path
k0s <k0scist@gmail.com>
parents:
1
diff
changeset
|
28 directories = [ f for f in files if os.path.isdir(f) ] |
0d9094bb98b0
adding function to return all hg repos on a path
k0s <k0scist@gmail.com>
parents:
1
diff
changeset
|
29 |
0d9094bb98b0
adding function to return all hg repos on a path
k0s <k0scist@gmail.com>
parents:
1
diff
changeset
|
30 repos = [] |
0d9094bb98b0
adding function to return all hg repos on a path
k0s <k0scist@gmail.com>
parents:
1
diff
changeset
|
31 for d in directories: |
0d9094bb98b0
adding function to return all hg repos on a path
k0s <k0scist@gmail.com>
parents:
1
diff
changeset
|
32 try: |
0d9094bb98b0
adding function to return all hg repos on a path
k0s <k0scist@gmail.com>
parents:
1
diff
changeset
|
33 repo = hg.repository(ui, d) |
0d9094bb98b0
adding function to return all hg repos on a path
k0s <k0scist@gmail.com>
parents:
1
diff
changeset
|
34 repos.append(os.path.basename(d)) |
0d9094bb98b0
adding function to return all hg repos on a path
k0s <k0scist@gmail.com>
parents:
1
diff
changeset
|
35 except mercurial.repo.RepoError: |
0d9094bb98b0
adding function to return all hg repos on a path
k0s <k0scist@gmail.com>
parents:
1
diff
changeset
|
36 pass |
0d9094bb98b0
adding function to return all hg repos on a path
k0s <k0scist@gmail.com>
parents:
1
diff
changeset
|
37 return repos |