Mercurial > hg > silvermirror
annotate silvermirror/hg.py @ 3:8a5d2083fbd1
adding stub for main()
author | k0s <k0scist@gmail.com> |
---|---|
date | Fri, 02 Oct 2009 19:04:19 -0400 |
parents | 0d9094bb98b0 |
children | 660c74f33ed2 |
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() | |
43 options, args = parser.parse_args(args) | |
44 if len(args) > 1: | |
45 raise NotImplementedError | |
46 | |
47 if __name__ == '__main__': | |
48 main() |