annotate hgrepo.py @ 257:75063203cfb5

Simple hack for handling wrong use of git repos (fixes issue 24 bb)
author Abderrahim Kitouni <a.kitouni@gmail.com>
date Thu, 08 Oct 2009 19:50:09 +0100
parents a3d54c38f214
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
246
a3d54c38f214 hgrepo: remove unused imports
Abderrahim Kitouni <a.kitouni@gmail.com>
parents: 240
diff changeset
1 from mercurial.node import bin
165
cb922a0ca22d almost got everything working
Scott Chacon <schacon@gmail.com>
parents:
diff changeset
2
179
c5c63783ace0 Initial clone/pull/push support for git repositories
Abderrahim Kitouni <a.kitouni@gmail.com>
parents: 178
diff changeset
3 from git_handler import GitHandler
c5c63783ace0 Initial clone/pull/push support for git repositories
Abderrahim Kitouni <a.kitouni@gmail.com>
parents: 178
diff changeset
4 from gitrepo import gitrepo
c5c63783ace0 Initial clone/pull/push support for git repositories
Abderrahim Kitouni <a.kitouni@gmail.com>
parents: 178
diff changeset
5
c5c63783ace0 Initial clone/pull/push support for git repositories
Abderrahim Kitouni <a.kitouni@gmail.com>
parents: 178
diff changeset
6
206
5986ac6a591e create the repository subclass in reposetup
Abderrahim Kitouni <a.kitouni@gmail.com>
parents: 204
diff changeset
7 def generate_repo_subclass(baseclass):
5986ac6a591e create the repository subclass in reposetup
Abderrahim Kitouni <a.kitouni@gmail.com>
parents: 204
diff changeset
8 class hgrepo(baseclass):
5986ac6a591e create the repository subclass in reposetup
Abderrahim Kitouni <a.kitouni@gmail.com>
parents: 204
diff changeset
9 def pull(self, remote, heads=None, force=False):
5986ac6a591e create the repository subclass in reposetup
Abderrahim Kitouni <a.kitouni@gmail.com>
parents: 204
diff changeset
10 if isinstance(remote, gitrepo):
5986ac6a591e create the repository subclass in reposetup
Abderrahim Kitouni <a.kitouni@gmail.com>
parents: 204
diff changeset
11 git = GitHandler(self, self.ui)
232
0ba1aee0467c initial support for pull -r
Abderrahim Kitouni <a.kitouni@gmail.com>
parents: 231
diff changeset
12 git.fetch(remote.path, heads)
215
b5d4d1552765 add some annotations for test coverage
Abderrahim Kitouni <a.kitouni@gmail.com>
parents: 210
diff changeset
13 else: #pragma: no cover
218
07de94478059 hgrepo: forward the return value of pull and push (fixes issue 8 bb)
Abderrahim Kitouni <a.kitouni@gmail.com>
parents: 217
diff changeset
14 return super(hgrepo, self).pull(remote, heads, force)
206
5986ac6a591e create the repository subclass in reposetup
Abderrahim Kitouni <a.kitouni@gmail.com>
parents: 204
diff changeset
15
5986ac6a591e create the repository subclass in reposetup
Abderrahim Kitouni <a.kitouni@gmail.com>
parents: 204
diff changeset
16 def push(self, remote, force=False, revs=None):
5986ac6a591e create the repository subclass in reposetup
Abderrahim Kitouni <a.kitouni@gmail.com>
parents: 204
diff changeset
17 if isinstance(remote, gitrepo):
5986ac6a591e create the repository subclass in reposetup
Abderrahim Kitouni <a.kitouni@gmail.com>
parents: 204
diff changeset
18 git = GitHandler(self, self.ui)
230
51e4d6ebbc40 rework pushing to support --rev and --force options
Abderrahim Kitouni <a.kitouni@gmail.com>
parents: 226
diff changeset
19 git.push(remote.path, revs, force)
215
b5d4d1552765 add some annotations for test coverage
Abderrahim Kitouni <a.kitouni@gmail.com>
parents: 210
diff changeset
20 else: #pragma: no cover
218
07de94478059 hgrepo: forward the return value of pull and push (fixes issue 8 bb)
Abderrahim Kitouni <a.kitouni@gmail.com>
parents: 217
diff changeset
21 return super(hgrepo, self).push(remote, force, revs)
165
cb922a0ca22d almost got everything working
Scott Chacon <schacon@gmail.com>
parents:
diff changeset
22
231
bdaec2a079ce initial support for 'hg outgoing'
Abderrahim Kitouni <a.kitouni@gmail.com>
parents: 230
diff changeset
23 def findoutgoing(self, remote, base=None, heads=None, force=False):
bdaec2a079ce initial support for 'hg outgoing'
Abderrahim Kitouni <a.kitouni@gmail.com>
parents: 230
diff changeset
24 if isinstance(remote, gitrepo):
bdaec2a079ce initial support for 'hg outgoing'
Abderrahim Kitouni <a.kitouni@gmail.com>
parents: 230
diff changeset
25 git = GitHandler(self, self.ui)
bdaec2a079ce initial support for 'hg outgoing'
Abderrahim Kitouni <a.kitouni@gmail.com>
parents: 230
diff changeset
26 base, heads = git.get_refs(remote.path)
bdaec2a079ce initial support for 'hg outgoing'
Abderrahim Kitouni <a.kitouni@gmail.com>
parents: 230
diff changeset
27 out, h = super(hgrepo, self).findoutgoing(remote, base, heads, force)
bdaec2a079ce initial support for 'hg outgoing'
Abderrahim Kitouni <a.kitouni@gmail.com>
parents: 230
diff changeset
28 return out
bdaec2a079ce initial support for 'hg outgoing'
Abderrahim Kitouni <a.kitouni@gmail.com>
parents: 230
diff changeset
29 else: #pragma: no cover
bdaec2a079ce initial support for 'hg outgoing'
Abderrahim Kitouni <a.kitouni@gmail.com>
parents: 230
diff changeset
30 return super(hgrepo, self).findoutgoing(remote, base, heads, force)
bdaec2a079ce initial support for 'hg outgoing'
Abderrahim Kitouni <a.kitouni@gmail.com>
parents: 230
diff changeset
31
240
237f0c0c02dc handle the new tag cache in mercurial crew
Abderrahim Kitouni <a.kitouni@gmail.com>
parents: 232
diff changeset
32 def _findtags(self):
237f0c0c02dc handle the new tag cache in mercurial crew
Abderrahim Kitouni <a.kitouni@gmail.com>
parents: 232
diff changeset
33 (tags, tagtypes) = super(hgrepo, self)._findtags()
237f0c0c02dc handle the new tag cache in mercurial crew
Abderrahim Kitouni <a.kitouni@gmail.com>
parents: 232
diff changeset
34
237f0c0c02dc handle the new tag cache in mercurial crew
Abderrahim Kitouni <a.kitouni@gmail.com>
parents: 232
diff changeset
35 git = GitHandler(self, self.ui)
237f0c0c02dc handle the new tag cache in mercurial crew
Abderrahim Kitouni <a.kitouni@gmail.com>
parents: 232
diff changeset
36 for tag, rev in git.tags.iteritems():
237f0c0c02dc handle the new tag cache in mercurial crew
Abderrahim Kitouni <a.kitouni@gmail.com>
parents: 232
diff changeset
37 if tag in tags:
237f0c0c02dc handle the new tag cache in mercurial crew
Abderrahim Kitouni <a.kitouni@gmail.com>
parents: 232
diff changeset
38 continue
237f0c0c02dc handle the new tag cache in mercurial crew
Abderrahim Kitouni <a.kitouni@gmail.com>
parents: 232
diff changeset
39
237f0c0c02dc handle the new tag cache in mercurial crew
Abderrahim Kitouni <a.kitouni@gmail.com>
parents: 232
diff changeset
40 tags[tag] = bin(rev)
237f0c0c02dc handle the new tag cache in mercurial crew
Abderrahim Kitouni <a.kitouni@gmail.com>
parents: 232
diff changeset
41 tagtypes[tag] = 'git'
237f0c0c02dc handle the new tag cache in mercurial crew
Abderrahim Kitouni <a.kitouni@gmail.com>
parents: 232
diff changeset
42
237f0c0c02dc handle the new tag cache in mercurial crew
Abderrahim Kitouni <a.kitouni@gmail.com>
parents: 232
diff changeset
43 return (tags, tagtypes)
237f0c0c02dc handle the new tag cache in mercurial crew
Abderrahim Kitouni <a.kitouni@gmail.com>
parents: 232
diff changeset
44
206
5986ac6a591e create the repository subclass in reposetup
Abderrahim Kitouni <a.kitouni@gmail.com>
parents: 204
diff changeset
45 def tags(self):
240
237f0c0c02dc handle the new tag cache in mercurial crew
Abderrahim Kitouni <a.kitouni@gmail.com>
parents: 232
diff changeset
46 if not hasattr(self, 'tagscache'):
237f0c0c02dc handle the new tag cache in mercurial crew
Abderrahim Kitouni <a.kitouni@gmail.com>
parents: 232
diff changeset
47 # mercurial 1.4
237f0c0c02dc handle the new tag cache in mercurial crew
Abderrahim Kitouni <a.kitouni@gmail.com>
parents: 232
diff changeset
48 return super(hgrepo, self).tags()
237f0c0c02dc handle the new tag cache in mercurial crew
Abderrahim Kitouni <a.kitouni@gmail.com>
parents: 232
diff changeset
49
206
5986ac6a591e create the repository subclass in reposetup
Abderrahim Kitouni <a.kitouni@gmail.com>
parents: 204
diff changeset
50 if self.tagscache:
5986ac6a591e create the repository subclass in reposetup
Abderrahim Kitouni <a.kitouni@gmail.com>
parents: 204
diff changeset
51 return self.tagscache
187
5f196f80ffb3 Store git tags in .hg/git-tags and let localtags be *local*
Abderrahim Kitouni <a.kitouni@gmail.com>
parents: 182
diff changeset
52
206
5986ac6a591e create the repository subclass in reposetup
Abderrahim Kitouni <a.kitouni@gmail.com>
parents: 204
diff changeset
53 git = GitHandler(self, self.ui)
5986ac6a591e create the repository subclass in reposetup
Abderrahim Kitouni <a.kitouni@gmail.com>
parents: 204
diff changeset
54 tagscache = super(hgrepo, self).tags()
240
237f0c0c02dc handle the new tag cache in mercurial crew
Abderrahim Kitouni <a.kitouni@gmail.com>
parents: 232
diff changeset
55 for tag, rev in git.tags.iteritems():
237f0c0c02dc handle the new tag cache in mercurial crew
Abderrahim Kitouni <a.kitouni@gmail.com>
parents: 232
diff changeset
56 if tag in tagscache:
237f0c0c02dc handle the new tag cache in mercurial crew
Abderrahim Kitouni <a.kitouni@gmail.com>
parents: 232
diff changeset
57 continue
237f0c0c02dc handle the new tag cache in mercurial crew
Abderrahim Kitouni <a.kitouni@gmail.com>
parents: 232
diff changeset
58
237f0c0c02dc handle the new tag cache in mercurial crew
Abderrahim Kitouni <a.kitouni@gmail.com>
parents: 232
diff changeset
59 tagscache[tag] = bin(rev)
237f0c0c02dc handle the new tag cache in mercurial crew
Abderrahim Kitouni <a.kitouni@gmail.com>
parents: 232
diff changeset
60 self._tagstypecache[tag] = 'git'
237f0c0c02dc handle the new tag cache in mercurial crew
Abderrahim Kitouni <a.kitouni@gmail.com>
parents: 232
diff changeset
61
206
5986ac6a591e create the repository subclass in reposetup
Abderrahim Kitouni <a.kitouni@gmail.com>
parents: 204
diff changeset
62 return tagscache
187
5f196f80ffb3 Store git tags in .hg/git-tags and let localtags be *local*
Abderrahim Kitouni <a.kitouni@gmail.com>
parents: 182
diff changeset
63
206
5986ac6a591e create the repository subclass in reposetup
Abderrahim Kitouni <a.kitouni@gmail.com>
parents: 204
diff changeset
64 return hgrepo