Mercurial > hg > silvermirror
annotate silvermirror/hg.py @ 5:660c74f33ed2
adding more to skeleton for main program
author | k0s <k0scist@gmail.com> |
---|---|
date | Sat, 03 Oct 2009 18:10:11 -0400 |
parents | 8a5d2083fbd1 |
children | c999b2f16159 |
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 |
3 | 7 import sys |
1
9b139702a8f9
use a real backend architecture with an inteface and vastly simplify unify.py
k0s <k0scist@gmail.com>
parents:
diff
changeset
|
8 from mercurial import commands, hg, ui |
3 | 9 from optparse import OptionParser |
1
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 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
|
12 """ |
9b139702a8f9
use a real backend architecture with an inteface and vastly simplify unify.py
k0s <k0scist@gmail.com>
parents:
diff
changeset
|
13 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
|
14 """ |
9b139702a8f9
use a real backend architecture with an inteface and vastly simplify unify.py
k0s <k0scist@gmail.com>
parents:
diff
changeset
|
15 ui = ui.ui() |
9b139702a8f9
use a real backend architecture with an inteface and vastly simplify unify.py
k0s <k0scist@gmail.com>
parents:
diff
changeset
|
16 try: |
9b139702a8f9
use a real backend architecture with an inteface and vastly simplify unify.py
k0s <k0scist@gmail.com>
parents:
diff
changeset
|
17 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
|
18 command = commands.pull |
9b139702a8f9
use a real backend architecture with an inteface and vastly simplify unify.py
k0s <k0scist@gmail.com>
parents:
diff
changeset
|
19 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
|
20 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
|
21 command = commands.clone |
2
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 def repositories(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 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
|
26 """ |
0d9094bb98b0
adding function to return all hg repos on a path
k0s <k0scist@gmail.com>
parents:
1
diff
changeset
|
27 |
0d9094bb98b0
adding function to return all hg repos on a path
k0s <k0scist@gmail.com>
parents:
1
diff
changeset
|
28 ui = ui.ui() |
0d9094bb98b0
adding function to return all hg repos on a path
k0s <k0scist@gmail.com>
parents:
1
diff
changeset
|
29 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
|
30 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
|
31 |
0d9094bb98b0
adding function to return all hg repos on a path
k0s <k0scist@gmail.com>
parents:
1
diff
changeset
|
32 repos = [] |
0d9094bb98b0
adding function to return all hg repos on a path
k0s <k0scist@gmail.com>
parents:
1
diff
changeset
|
33 for d in directories: |
0d9094bb98b0
adding function to return all hg repos on a path
k0s <k0scist@gmail.com>
parents:
1
diff
changeset
|
34 try: |
0d9094bb98b0
adding function to return all hg repos on a path
k0s <k0scist@gmail.com>
parents:
1
diff
changeset
|
35 repo = hg.repository(ui, d) |
0d9094bb98b0
adding function to return all hg repos on a path
k0s <k0scist@gmail.com>
parents:
1
diff
changeset
|
36 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
|
37 except mercurial.repo.RepoError: |
0d9094bb98b0
adding function to return all hg repos on a path
k0s <k0scist@gmail.com>
parents:
1
diff
changeset
|
38 pass |
0d9094bb98b0
adding function to return all hg repos on a path
k0s <k0scist@gmail.com>
parents:
1
diff
changeset
|
39 return repos |
3 | 40 |
41 def main(args=sys.argv[1:]): | |
42 parser = OptionParser() | |
5
660c74f33ed2
adding more to skeleton for main program
k0s <k0scist@gmail.com>
parents:
3
diff
changeset
|
43 parser.add_option('-H', '--host', dest='host') |
3 | 44 options, args = parser.parse_args(args) |
5
660c74f33ed2
adding more to skeleton for main program
k0s <k0scist@gmail.com>
parents:
3
diff
changeset
|
45 if len(args) != 1: |
660c74f33ed2
adding more to skeleton for main program
k0s <k0scist@gmail.com>
parents:
3
diff
changeset
|
46 parser.print_usage() |
660c74f33ed2
adding more to skeleton for main program
k0s <k0scist@gmail.com>
parents:
3
diff
changeset
|
47 parser.exit() |
3 | 48 |
49 if __name__ == '__main__': | |
50 main() |