Mercurial > hg > hg-git
annotate hggit/gitrepo.py @ 556:affd119533ae
peer: pass localrepo to new gitrepo instances
This change wraps hg.peer to allow for capturing the repo object. It is then
passed in to new gitrepo instanceds. This will be needed to implement later
functionality, such as richer bookmark support using pushkeys.
author | David M. Carr <david@carrclan.us> |
---|---|
date | Thu, 25 Oct 2012 19:54:05 -0400 (2012-10-25) |
parents | 62aaacc44c14 |
children | 4f4ab2d89375 |
rev | line source |
---|---|
461
de618e24dcdd
gitrepo: cope with module/class renames in hg 2.3
Bryan O'Sullivan <bryano@fb.com>
parents:
458
diff
changeset
|
1 from mercurial import util |
257
75063203cfb5
Simple hack for handling wrong use of git repos (fixes issue 24 bb)
Abderrahim Kitouni <a.kitouni@gmail.com>
parents:
232
diff
changeset
|
2 try: |
75063203cfb5
Simple hack for handling wrong use of git repos (fixes issue 24 bb)
Abderrahim Kitouni <a.kitouni@gmail.com>
parents:
232
diff
changeset
|
3 from mercurial.error import RepoError |
75063203cfb5
Simple hack for handling wrong use of git repos (fixes issue 24 bb)
Abderrahim Kitouni <a.kitouni@gmail.com>
parents:
232
diff
changeset
|
4 except ImportError: |
75063203cfb5
Simple hack for handling wrong use of git repos (fixes issue 24 bb)
Abderrahim Kitouni <a.kitouni@gmail.com>
parents:
232
diff
changeset
|
5 from mercurial.repo import RepoError |
75063203cfb5
Simple hack for handling wrong use of git repos (fixes issue 24 bb)
Abderrahim Kitouni <a.kitouni@gmail.com>
parents:
232
diff
changeset
|
6 |
461
de618e24dcdd
gitrepo: cope with module/class renames in hg 2.3
Bryan O'Sullivan <bryano@fb.com>
parents:
458
diff
changeset
|
7 try: |
462
406ed78809b2
gitrepo: correct capitalization of peerrepository
Augie Fackler <raf@durin42.com>
parents:
461
diff
changeset
|
8 from mercurial.peer import peerrepository |
461
de618e24dcdd
gitrepo: cope with module/class renames in hg 2.3
Bryan O'Sullivan <bryano@fb.com>
parents:
458
diff
changeset
|
9 except ImportError: |
463
7e98801a8381
repository in mercurial.repo.py starts with lowercase
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
462
diff
changeset
|
10 from mercurial.repo import repository as peerrepository |
461
de618e24dcdd
gitrepo: cope with module/class renames in hg 2.3
Bryan O'Sullivan <bryano@fb.com>
parents:
458
diff
changeset
|
11 |
60
05a96f7750ad
add support for `hg clone git://github.com/defunkt/facebox.git`
Chris Wanstrath <chris@ozmm.org>
parents:
diff
changeset
|
12 from git_handler import GitHandler |
05a96f7750ad
add support for `hg clone git://github.com/defunkt/facebox.git`
Chris Wanstrath <chris@ozmm.org>
parents:
diff
changeset
|
13 |
462
406ed78809b2
gitrepo: correct capitalization of peerrepository
Augie Fackler <raf@durin42.com>
parents:
461
diff
changeset
|
14 class gitrepo(peerrepository): |
232
0ba1aee0467c
initial support for pull -r
Abderrahim Kitouni <a.kitouni@gmail.com>
parents:
215
diff
changeset
|
15 capabilities = ['lookup'] |
347
2efbee89d3f7
gitrepo: update for pushable bookmarks
Augie Fackler <durin42@gmail.com>
parents:
344
diff
changeset
|
16 |
465
62aaacc44c14
girepo: add _capabilities method expected after the peer refactor
Augie Fackler <raf@durin42.com>
parents:
463
diff
changeset
|
17 def _capabilities(self): |
62aaacc44c14
girepo: add _capabilities method expected after the peer refactor
Augie Fackler <raf@durin42.com>
parents:
463
diff
changeset
|
18 return self.capabilities |
62aaacc44c14
girepo: add _capabilities method expected after the peer refactor
Augie Fackler <raf@durin42.com>
parents:
463
diff
changeset
|
19 |
179
c5c63783ace0
Initial clone/pull/push support for git repositories
Abderrahim Kitouni <a.kitouni@gmail.com>
parents:
61
diff
changeset
|
20 def __init__(self, ui, path, create): |
215
b5d4d1552765
add some annotations for test coverage
Abderrahim Kitouni <a.kitouni@gmail.com>
parents:
206
diff
changeset
|
21 if create: # pragma: no cover |
179
c5c63783ace0
Initial clone/pull/push support for git repositories
Abderrahim Kitouni <a.kitouni@gmail.com>
parents:
61
diff
changeset
|
22 raise util.Abort('Cannot create a git repository.') |
257
75063203cfb5
Simple hack for handling wrong use of git repos (fixes issue 24 bb)
Abderrahim Kitouni <a.kitouni@gmail.com>
parents:
232
diff
changeset
|
23 self.ui = ui |
179
c5c63783ace0
Initial clone/pull/push support for git repositories
Abderrahim Kitouni <a.kitouni@gmail.com>
parents:
61
diff
changeset
|
24 self.path = path |
556
affd119533ae
peer: pass localrepo to new gitrepo instances
David M. Carr <david@carrclan.us>
parents:
465
diff
changeset
|
25 self.localrepo = None |
347
2efbee89d3f7
gitrepo: update for pushable bookmarks
Augie Fackler <durin42@gmail.com>
parents:
344
diff
changeset
|
26 |
458
dfb2b7b5d586
gitrepo: add url() attribute to fix subrepo support
Augie Fackler <raf@durin42.com>
parents:
409
diff
changeset
|
27 def url(self): |
dfb2b7b5d586
gitrepo: add url() attribute to fix subrepo support
Augie Fackler <raf@durin42.com>
parents:
409
diff
changeset
|
28 return self.path |
dfb2b7b5d586
gitrepo: add url() attribute to fix subrepo support
Augie Fackler <raf@durin42.com>
parents:
409
diff
changeset
|
29 |
232
0ba1aee0467c
initial support for pull -r
Abderrahim Kitouni <a.kitouni@gmail.com>
parents:
215
diff
changeset
|
30 def lookup(self, key): |
0ba1aee0467c
initial support for pull -r
Abderrahim Kitouni <a.kitouni@gmail.com>
parents:
215
diff
changeset
|
31 if isinstance(key, str): |
0ba1aee0467c
initial support for pull -r
Abderrahim Kitouni <a.kitouni@gmail.com>
parents:
215
diff
changeset
|
32 return key |
347
2efbee89d3f7
gitrepo: update for pushable bookmarks
Augie Fackler <durin42@gmail.com>
parents:
344
diff
changeset
|
33 |
257
75063203cfb5
Simple hack for handling wrong use of git repos (fixes issue 24 bb)
Abderrahim Kitouni <a.kitouni@gmail.com>
parents:
232
diff
changeset
|
34 def local(self): |
75063203cfb5
Simple hack for handling wrong use of git repos (fixes issue 24 bb)
Abderrahim Kitouni <a.kitouni@gmail.com>
parents:
232
diff
changeset
|
35 if not self.path: |
75063203cfb5
Simple hack for handling wrong use of git repos (fixes issue 24 bb)
Abderrahim Kitouni <a.kitouni@gmail.com>
parents:
232
diff
changeset
|
36 raise RepoError |
347
2efbee89d3f7
gitrepo: update for pushable bookmarks
Augie Fackler <durin42@gmail.com>
parents:
344
diff
changeset
|
37 |
344
af48a5961432
Add just enough code to handle changes to cset discovery.
Augie Fackler <durin42@gmail.com>
parents:
260
diff
changeset
|
38 def heads(self): |
af48a5961432
Add just enough code to handle changes to cset discovery.
Augie Fackler <durin42@gmail.com>
parents:
260
diff
changeset
|
39 return [] |
257
75063203cfb5
Simple hack for handling wrong use of git repos (fixes issue 24 bb)
Abderrahim Kitouni <a.kitouni@gmail.com>
parents:
232
diff
changeset
|
40 |
347
2efbee89d3f7
gitrepo: update for pushable bookmarks
Augie Fackler <durin42@gmail.com>
parents:
344
diff
changeset
|
41 def listkeys(self, namespace): |
2efbee89d3f7
gitrepo: update for pushable bookmarks
Augie Fackler <durin42@gmail.com>
parents:
344
diff
changeset
|
42 return {} |
2efbee89d3f7
gitrepo: update for pushable bookmarks
Augie Fackler <durin42@gmail.com>
parents:
344
diff
changeset
|
43 |
2efbee89d3f7
gitrepo: update for pushable bookmarks
Augie Fackler <durin42@gmail.com>
parents:
344
diff
changeset
|
44 def pushkey(self, namespace, key, old, new): |
2efbee89d3f7
gitrepo: update for pushable bookmarks
Augie Fackler <durin42@gmail.com>
parents:
344
diff
changeset
|
45 return False |
2efbee89d3f7
gitrepo: update for pushable bookmarks
Augie Fackler <durin42@gmail.com>
parents:
344
diff
changeset
|
46 |
409
2e773ed95066
Prevent exception in incoming with hg <= 1.6
Brendan Cully <brendan@kublai.com>
parents:
402
diff
changeset
|
47 # used by incoming in hg <= 1.6 |
2e773ed95066
Prevent exception in incoming with hg <= 1.6
Brendan Cully <brendan@kublai.com>
parents:
402
diff
changeset
|
48 def branches(self, nodes): |
2e773ed95066
Prevent exception in incoming with hg <= 1.6
Brendan Cully <brendan@kublai.com>
parents:
402
diff
changeset
|
49 return [] |
60
05a96f7750ad
add support for `hg clone git://github.com/defunkt/facebox.git`
Chris Wanstrath <chris@ozmm.org>
parents:
diff
changeset
|
50 |
05a96f7750ad
add support for `hg clone git://github.com/defunkt/facebox.git`
Chris Wanstrath <chris@ozmm.org>
parents:
diff
changeset
|
51 instance = gitrepo |
402 | 52 |
53 def islocal(path): | |
54 u = util.url(path) | |
55 return not u.scheme or u.scheme == 'file' |