Mercurial > hg-git
annotate hggit/__init__.py @ 442:553dd7078058
Update for newer dulwich and hg versions.
author | Augie Fackler <durin42@gmail.com> |
---|---|
date | Fri, 27 Jan 2012 11:06:27 -0600 |
parents | 3f45c88100e8 |
children | 9df1741f3977 |
rev | line source |
---|---|
0
06366111af3c
initial import of the hg-git bridging extension for mercurial
Scott Chacon <schacon@gmail.com>
parents:
diff
changeset
|
1 # git.py - git server bridge |
06366111af3c
initial import of the hg-git bridging extension for mercurial
Scott Chacon <schacon@gmail.com>
parents:
diff
changeset
|
2 # |
06366111af3c
initial import of the hg-git bridging extension for mercurial
Scott Chacon <schacon@gmail.com>
parents:
diff
changeset
|
3 # Copyright 2008 Scott Chacon <schacon at gmail dot com> |
250 | 4 # also some code (and help) borrowed from durin42 |
0
06366111af3c
initial import of the hg-git bridging extension for mercurial
Scott Chacon <schacon@gmail.com>
parents:
diff
changeset
|
5 # |
06366111af3c
initial import of the hg-git bridging extension for mercurial
Scott Chacon <schacon@gmail.com>
parents:
diff
changeset
|
6 # This software may be used and distributed according to the terms |
06366111af3c
initial import of the hg-git bridging extension for mercurial
Scott Chacon <schacon@gmail.com>
parents:
diff
changeset
|
7 # of the GNU General Public License, incorporated herein by reference. |
06366111af3c
initial import of the hg-git bridging extension for mercurial
Scott Chacon <schacon@gmail.com>
parents:
diff
changeset
|
8 |
06366111af3c
initial import of the hg-git bridging extension for mercurial
Scott Chacon <schacon@gmail.com>
parents:
diff
changeset
|
9 '''push and pull from a Git server |
06366111af3c
initial import of the hg-git bridging extension for mercurial
Scott Chacon <schacon@gmail.com>
parents:
diff
changeset
|
10 |
06366111af3c
initial import of the hg-git bridging extension for mercurial
Scott Chacon <schacon@gmail.com>
parents:
diff
changeset
|
11 This extension lets you communicate (push and pull) with a Git server. |
250 | 12 This way you can use Git hosting for your project or collaborate with a |
0
06366111af3c
initial import of the hg-git bridging extension for mercurial
Scott Chacon <schacon@gmail.com>
parents:
diff
changeset
|
13 project that is in Git. A bridger of worlds, this plugin be. |
06366111af3c
initial import of the hg-git bridging extension for mercurial
Scott Chacon <schacon@gmail.com>
parents:
diff
changeset
|
14 |
250 | 15 Try hg clone git:// or hg clone git+ssh:// |
0
06366111af3c
initial import of the hg-git bridging extension for mercurial
Scott Chacon <schacon@gmail.com>
parents:
diff
changeset
|
16 ''' |
06366111af3c
initial import of the hg-git bridging extension for mercurial
Scott Chacon <schacon@gmail.com>
parents:
diff
changeset
|
17 |
351
dd90394cd13b
findoutgoing: update wrapper for hg change 98c874a929f1
Augie Fackler <durin42@gmail.com>
parents:
344
diff
changeset
|
18 import inspect |
256
442fe2ca104d
Simpler handling of detection of git repos
Mads Kiilerich <mads@kiilerich.com>
parents:
220
diff
changeset
|
19 import os |
442fe2ca104d
Simpler handling of detection of git repos
Mads Kiilerich <mads@kiilerich.com>
parents:
220
diff
changeset
|
20 |
408 | 21 from mercurial import bundlerepo |
334
eb345bacc1da
Cope with tags being sorted (hg cset c7dbd6c4877a) by backporting that behavior
Augie Fackler <durin42@gmail.com>
parents:
320
diff
changeset
|
22 from mercurial import commands |
362
5b6961384ee2
demandimport: defend against collections breakage in new dulwich
Augie Fackler <durin42@gmail.com>
parents:
352
diff
changeset
|
23 from mercurial import demandimport |
334
eb345bacc1da
Cope with tags being sorted (hg cset c7dbd6c4877a) by backporting that behavior
Augie Fackler <durin42@gmail.com>
parents:
320
diff
changeset
|
24 from mercurial import extensions |
eb345bacc1da
Cope with tags being sorted (hg cset c7dbd6c4877a) by backporting that behavior
Augie Fackler <durin42@gmail.com>
parents:
320
diff
changeset
|
25 from mercurial import hg |
eb345bacc1da
Cope with tags being sorted (hg cset c7dbd6c4877a) by backporting that behavior
Augie Fackler <durin42@gmail.com>
parents:
320
diff
changeset
|
26 from mercurial import localrepo |
eb345bacc1da
Cope with tags being sorted (hg cset c7dbd6c4877a) by backporting that behavior
Augie Fackler <durin42@gmail.com>
parents:
320
diff
changeset
|
27 from mercurial import util as hgutil |
383
61865ad88740
compatibility with new url handling in Mercurial 1.9
Mads Kiilerich <mads@kiilerich.com>
parents:
373
diff
changeset
|
28 from mercurial import url |
0
06366111af3c
initial import of the hg-git bridging extension for mercurial
Scott Chacon <schacon@gmail.com>
parents:
diff
changeset
|
29 from mercurial.i18n import _ |
220
211fa793d74f
support local git repositories (fixes issue 5 bb)
Abderrahim Kitouni <a.kitouni@gmail.com>
parents:
210
diff
changeset
|
30 |
362
5b6961384ee2
demandimport: defend against collections breakage in new dulwich
Augie Fackler <durin42@gmail.com>
parents:
352
diff
changeset
|
31 demandimport.ignore.extend([ |
5b6961384ee2
demandimport: defend against collections breakage in new dulwich
Augie Fackler <durin42@gmail.com>
parents:
352
diff
changeset
|
32 'collections', |
5b6961384ee2
demandimport: defend against collections breakage in new dulwich
Augie Fackler <durin42@gmail.com>
parents:
352
diff
changeset
|
33 ]) |
5b6961384ee2
demandimport: defend against collections breakage in new dulwich
Augie Fackler <durin42@gmail.com>
parents:
352
diff
changeset
|
34 |
210
9a27c618d0ed
remove broken tagging code (see issue 3 bb)
Abderrahim Kitouni <a.kitouni@gmail.com>
parents:
206
diff
changeset
|
35 import gitrepo, hgrepo |
5
d6c443a91b18
refactored the git handling stuff out into another class
Scott Chacon <schacon@gmail.com>
parents:
4
diff
changeset
|
36 from git_handler import GitHandler |
0
06366111af3c
initial import of the hg-git bridging extension for mercurial
Scott Chacon <schacon@gmail.com>
parents:
diff
changeset
|
37 |
60
05a96f7750ad
add support for `hg clone git://github.com/defunkt/facebox.git`
Chris Wanstrath <chris@ozmm.org>
parents:
59
diff
changeset
|
38 # support for `hg clone git://github.com/defunkt/facebox.git` |
168
8bfa8aa6b68f
added empty changelog handling
Scott Chacon <schacon@gmail.com>
parents:
165
diff
changeset
|
39 # also hg clone git+ssh://git@github.com/schacon/simplegit.git |
439
3f45c88100e8
add support for the HTTP smart protocol when using Dulwich tip
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
430
diff
changeset
|
40 _gitschemes = ('git', 'git+ssh', 'git+http', 'git+https') |
3f45c88100e8
add support for the HTTP smart protocol when using Dulwich tip
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
430
diff
changeset
|
41 for _scheme in _gitschemes: |
3f45c88100e8
add support for the HTTP smart protocol when using Dulwich tip
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
430
diff
changeset
|
42 hg.schemes[_scheme] = gitrepo |
180
682863000e9a
Make it possible to clone/pull from bundle repositories
Abderrahim Kitouni <a.kitouni@gmail.com>
parents:
175
diff
changeset
|
43 |
256
442fe2ca104d
Simpler handling of detection of git repos
Mads Kiilerich <mads@kiilerich.com>
parents:
220
diff
changeset
|
44 # support for `hg clone localgitrepo` |
220
211fa793d74f
support local git repositories (fixes issue 5 bb)
Abderrahim Kitouni <a.kitouni@gmail.com>
parents:
210
diff
changeset
|
45 _oldlocal = hg.schemes['file'] |
211fa793d74f
support local git repositories (fixes issue 5 bb)
Abderrahim Kitouni <a.kitouni@gmail.com>
parents:
210
diff
changeset
|
46 |
388
bcc79fa3fe09
url wasn't ever published as url.url, and is now util.url
Augie Fackler <durin42@gmail.com>
parents:
383
diff
changeset
|
47 try: |
bcc79fa3fe09
url wasn't ever published as url.url, and is now util.url
Augie Fackler <durin42@gmail.com>
parents:
383
diff
changeset
|
48 urlcls = hgutil.url |
bcc79fa3fe09
url wasn't ever published as url.url, and is now util.url
Augie Fackler <durin42@gmail.com>
parents:
383
diff
changeset
|
49 except AttributeError: |
bcc79fa3fe09
url wasn't ever published as url.url, and is now util.url
Augie Fackler <durin42@gmail.com>
parents:
383
diff
changeset
|
50 class urlcls(object): |
bcc79fa3fe09
url wasn't ever published as url.url, and is now util.url
Augie Fackler <durin42@gmail.com>
parents:
383
diff
changeset
|
51 def __init__(self, path): |
bcc79fa3fe09
url wasn't ever published as url.url, and is now util.url
Augie Fackler <durin42@gmail.com>
parents:
383
diff
changeset
|
52 self.p = hgutil.drop_scheme('file', path) |
bcc79fa3fe09
url wasn't ever published as url.url, and is now util.url
Augie Fackler <durin42@gmail.com>
parents:
383
diff
changeset
|
53 |
bcc79fa3fe09
url wasn't ever published as url.url, and is now util.url
Augie Fackler <durin42@gmail.com>
parents:
383
diff
changeset
|
54 def localpath(self): |
bcc79fa3fe09
url wasn't ever published as url.url, and is now util.url
Augie Fackler <durin42@gmail.com>
parents:
383
diff
changeset
|
55 return self.p |
bcc79fa3fe09
url wasn't ever published as url.url, and is now util.url
Augie Fackler <durin42@gmail.com>
parents:
383
diff
changeset
|
56 |
220
211fa793d74f
support local git repositories (fixes issue 5 bb)
Abderrahim Kitouni <a.kitouni@gmail.com>
parents:
210
diff
changeset
|
57 def _local(path): |
388
bcc79fa3fe09
url wasn't ever published as url.url, and is now util.url
Augie Fackler <durin42@gmail.com>
parents:
383
diff
changeset
|
58 p = urlcls(path).localpath() |
280 | 59 if (os.path.exists(os.path.join(p, '.git')) and |
256
442fe2ca104d
Simpler handling of detection of git repos
Mads Kiilerich <mads@kiilerich.com>
parents:
220
diff
changeset
|
60 not os.path.exists(os.path.join(p, '.hg'))): |
220
211fa793d74f
support local git repositories (fixes issue 5 bb)
Abderrahim Kitouni <a.kitouni@gmail.com>
parents:
210
diff
changeset
|
61 return gitrepo |
263
9f5a7a5d52aa
Enable detection of bare repositories as a local git repo
Lincoln Stoll <lstoll@lstoll.net>
parents:
260
diff
changeset
|
62 # detect a bare repository |
280 | 63 if (os.path.exists(os.path.join(p, 'HEAD')) and |
64 os.path.exists(os.path.join(p, 'objects')) and | |
65 os.path.exists(os.path.join(p, 'refs')) and | |
263
9f5a7a5d52aa
Enable detection of bare repositories as a local git repo
Lincoln Stoll <lstoll@lstoll.net>
parents:
260
diff
changeset
|
66 not os.path.exists(os.path.join(p, '.hg'))): |
9f5a7a5d52aa
Enable detection of bare repositories as a local git repo
Lincoln Stoll <lstoll@lstoll.net>
parents:
260
diff
changeset
|
67 return gitrepo |
256
442fe2ca104d
Simpler handling of detection of git repos
Mads Kiilerich <mads@kiilerich.com>
parents:
220
diff
changeset
|
68 return _oldlocal(path) |
220
211fa793d74f
support local git repositories (fixes issue 5 bb)
Abderrahim Kitouni <a.kitouni@gmail.com>
parents:
210
diff
changeset
|
69 |
211fa793d74f
support local git repositories (fixes issue 5 bb)
Abderrahim Kitouni <a.kitouni@gmail.com>
parents:
210
diff
changeset
|
70 hg.schemes['file'] = _local |
211fa793d74f
support local git repositories (fixes issue 5 bb)
Abderrahim Kitouni <a.kitouni@gmail.com>
parents:
210
diff
changeset
|
71 |
281
a14529b7b8f2
init: strip .git for default clone destination for git sources
Augie Fackler <durin42@gmail.com>
parents:
280
diff
changeset
|
72 hgdefaultdest = hg.defaultdest |
a14529b7b8f2
init: strip .git for default clone destination for git sources
Augie Fackler <durin42@gmail.com>
parents:
280
diff
changeset
|
73 def defaultdest(source): |
439
3f45c88100e8
add support for the HTTP smart protocol when using Dulwich tip
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
430
diff
changeset
|
74 for scheme in _gitschemes: |
281
a14529b7b8f2
init: strip .git for default clone destination for git sources
Augie Fackler <durin42@gmail.com>
parents:
280
diff
changeset
|
75 if source.startswith('%s://' % scheme) and source.endswith('.git'): |
a14529b7b8f2
init: strip .git for default clone destination for git sources
Augie Fackler <durin42@gmail.com>
parents:
280
diff
changeset
|
76 source = source[:-4] |
a14529b7b8f2
init: strip .git for default clone destination for git sources
Augie Fackler <durin42@gmail.com>
parents:
280
diff
changeset
|
77 break |
a14529b7b8f2
init: strip .git for default clone destination for git sources
Augie Fackler <durin42@gmail.com>
parents:
280
diff
changeset
|
78 return hgdefaultdest(source) |
a14529b7b8f2
init: strip .git for default clone destination for git sources
Augie Fackler <durin42@gmail.com>
parents:
280
diff
changeset
|
79 hg.defaultdest = defaultdest |
a14529b7b8f2
init: strip .git for default clone destination for git sources
Augie Fackler <durin42@gmail.com>
parents:
280
diff
changeset
|
80 |
297
a90fe3e8a8c3
hggit: defend against exceptions when pulling with -r
Augie Fackler <durin42@gmail.com>
parents:
296
diff
changeset
|
81 # defend against tracebacks if we specify -r in 'hg pull' |
a90fe3e8a8c3
hggit: defend against exceptions when pulling with -r
Augie Fackler <durin42@gmail.com>
parents:
296
diff
changeset
|
82 def safebranchrevs(orig, lrepo, repo, branches, revs): |
a90fe3e8a8c3
hggit: defend against exceptions when pulling with -r
Augie Fackler <durin42@gmail.com>
parents:
296
diff
changeset
|
83 revs, co = orig(lrepo, repo, branches, revs) |
a90fe3e8a8c3
hggit: defend against exceptions when pulling with -r
Augie Fackler <durin42@gmail.com>
parents:
296
diff
changeset
|
84 if getattr(lrepo, 'changelog', False) and co not in lrepo.changelog: |
a90fe3e8a8c3
hggit: defend against exceptions when pulling with -r
Augie Fackler <durin42@gmail.com>
parents:
296
diff
changeset
|
85 co = None |
a90fe3e8a8c3
hggit: defend against exceptions when pulling with -r
Augie Fackler <durin42@gmail.com>
parents:
296
diff
changeset
|
86 return revs, co |
300
eec31dee258e
Various hg 1.4 compat fixes.
Augie Fackler <durin42@gmail.com>
parents:
298
diff
changeset
|
87 if getattr(hg, 'addbranchrevs', False): |
eec31dee258e
Various hg 1.4 compat fixes.
Augie Fackler <durin42@gmail.com>
parents:
298
diff
changeset
|
88 extensions.wrapfunction(hg, 'addbranchrevs', safebranchrevs) |
297
a90fe3e8a8c3
hggit: defend against exceptions when pulling with -r
Augie Fackler <durin42@gmail.com>
parents:
296
diff
changeset
|
89 |
206
5986ac6a591e
create the repository subclass in reposetup
Abderrahim Kitouni <a.kitouni@gmail.com>
parents:
182
diff
changeset
|
90 def reposetup(ui, repo): |
296
32456f9cb7a4
hggit: don't wrap gitrepo with hgrepo
Augie Fackler <durin42@gmail.com>
parents:
281
diff
changeset
|
91 if not isinstance(repo, gitrepo.gitrepo): |
32456f9cb7a4
hggit: don't wrap gitrepo with hgrepo
Augie Fackler <durin42@gmail.com>
parents:
281
diff
changeset
|
92 klass = hgrepo.generate_repo_subclass(repo.__class__) |
32456f9cb7a4
hggit: don't wrap gitrepo with hgrepo
Augie Fackler <durin42@gmail.com>
parents:
281
diff
changeset
|
93 repo.__class__ = klass |
60
05a96f7750ad
add support for `hg clone git://github.com/defunkt/facebox.git`
Chris Wanstrath <chris@ozmm.org>
parents:
59
diff
changeset
|
94 |
137
5aefcbf1e50c
add a gimport command
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
136
diff
changeset
|
95 def gimport(ui, repo, remote_name=None): |
5aefcbf1e50c
add a gimport command
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
136
diff
changeset
|
96 git = GitHandler(repo, ui) |
5aefcbf1e50c
add a gimport command
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
136
diff
changeset
|
97 git.import_commits(remote_name) |
5aefcbf1e50c
add a gimport command
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
136
diff
changeset
|
98 |
97 | 99 def gexport(ui, repo): |
100 git = GitHandler(repo, ui) | |
136
74385b613bb7
rename export to export_commits for future consitency
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
134
diff
changeset
|
101 git.export_commits() |
97 | 102 |
40
f5b000ec7100
added gclear command to remove all the git data
Scott Chacon <schacon@gmail.com>
parents:
39
diff
changeset
|
103 def gclear(ui, repo): |
f5b000ec7100
added gclear command to remove all the git data
Scott Chacon <schacon@gmail.com>
parents:
39
diff
changeset
|
104 repo.ui.status(_("clearing out the git cache data\n")) |
f5b000ec7100
added gclear command to remove all the git data
Scott Chacon <schacon@gmail.com>
parents:
39
diff
changeset
|
105 git = GitHandler(repo, ui) |
f5b000ec7100
added gclear command to remove all the git data
Scott Chacon <schacon@gmail.com>
parents:
39
diff
changeset
|
106 git.clear() |
59
19d714ee9941
gfetch should access repo when printing, not dest_repo
Chris Wanstrath <chris@ozmm.org>
parents:
40
diff
changeset
|
107 |
298
6ad6945b6629
pull: make it possible to un-wedge the repo after stripping git revs
Augie Fackler <durin42@gmail.com>
parents:
297
diff
changeset
|
108 def git_cleanup(ui, repo): |
6ad6945b6629
pull: make it possible to un-wedge the repo after stripping git revs
Augie Fackler <durin42@gmail.com>
parents:
297
diff
changeset
|
109 new_map = [] |
6ad6945b6629
pull: make it possible to un-wedge the repo after stripping git revs
Augie Fackler <durin42@gmail.com>
parents:
297
diff
changeset
|
110 for line in repo.opener(GitHandler.mapfile): |
6ad6945b6629
pull: make it possible to un-wedge the repo after stripping git revs
Augie Fackler <durin42@gmail.com>
parents:
297
diff
changeset
|
111 gitsha, hgsha = line.strip().split(' ', 1) |
6ad6945b6629
pull: make it possible to un-wedge the repo after stripping git revs
Augie Fackler <durin42@gmail.com>
parents:
297
diff
changeset
|
112 if hgsha in repo: |
6ad6945b6629
pull: make it possible to un-wedge the repo after stripping git revs
Augie Fackler <durin42@gmail.com>
parents:
297
diff
changeset
|
113 new_map.append('%s %s\n' % (gitsha, hgsha)) |
6ad6945b6629
pull: make it possible to un-wedge the repo after stripping git revs
Augie Fackler <durin42@gmail.com>
parents:
297
diff
changeset
|
114 f = repo.opener(GitHandler.mapfile, 'wb') |
6ad6945b6629
pull: make it possible to un-wedge the repo after stripping git revs
Augie Fackler <durin42@gmail.com>
parents:
297
diff
changeset
|
115 map(f.write, new_map) |
6ad6945b6629
pull: make it possible to un-wedge the repo after stripping git revs
Augie Fackler <durin42@gmail.com>
parents:
297
diff
changeset
|
116 ui.status(_('git commit map cleaned\n')) |
6ad6945b6629
pull: make it possible to un-wedge the repo after stripping git revs
Augie Fackler <durin42@gmail.com>
parents:
297
diff
changeset
|
117 |
334
eb345bacc1da
Cope with tags being sorted (hg cset c7dbd6c4877a) by backporting that behavior
Augie Fackler <durin42@gmail.com>
parents:
320
diff
changeset
|
118 # drop this when we're 1.6-only, this just backports new behavior |
eb345bacc1da
Cope with tags being sorted (hg cset c7dbd6c4877a) by backporting that behavior
Augie Fackler <durin42@gmail.com>
parents:
320
diff
changeset
|
119 def sortednodetags(orig, *args, **kwargs): |
eb345bacc1da
Cope with tags being sorted (hg cset c7dbd6c4877a) by backporting that behavior
Augie Fackler <durin42@gmail.com>
parents:
320
diff
changeset
|
120 ret = orig(*args, **kwargs) |
eb345bacc1da
Cope with tags being sorted (hg cset c7dbd6c4877a) by backporting that behavior
Augie Fackler <durin42@gmail.com>
parents:
320
diff
changeset
|
121 ret.sort() |
eb345bacc1da
Cope with tags being sorted (hg cset c7dbd6c4877a) by backporting that behavior
Augie Fackler <durin42@gmail.com>
parents:
320
diff
changeset
|
122 return ret |
eb345bacc1da
Cope with tags being sorted (hg cset c7dbd6c4877a) by backporting that behavior
Augie Fackler <durin42@gmail.com>
parents:
320
diff
changeset
|
123 extensions.wrapfunction(localrepo.localrepository, 'nodetags', sortednodetags) |
eb345bacc1da
Cope with tags being sorted (hg cset c7dbd6c4877a) by backporting that behavior
Augie Fackler <durin42@gmail.com>
parents:
320
diff
changeset
|
124 |
344
af48a5961432
Add just enough code to handle changes to cset discovery.
Augie Fackler <durin42@gmail.com>
parents:
334
diff
changeset
|
125 try: |
af48a5961432
Add just enough code to handle changes to cset discovery.
Augie Fackler <durin42@gmail.com>
parents:
334
diff
changeset
|
126 from mercurial import discovery |
351
dd90394cd13b
findoutgoing: update wrapper for hg change 98c874a929f1
Augie Fackler <durin42@gmail.com>
parents:
344
diff
changeset
|
127 kwname = 'heads' |
373
23ca66eab3b5
Fix "hg outgoing" for mercurial versions which look like 1.6.x
Alexey Sokolov
parents:
372
diff
changeset
|
128 if hg.util.version() >= '1.7': |
351
dd90394cd13b
findoutgoing: update wrapper for hg change 98c874a929f1
Augie Fackler <durin42@gmail.com>
parents:
344
diff
changeset
|
129 kwname = 'remoteheads' |
389
5fdff9b8e742
Cope with new discovery code without crashing.
Augie Fackler <durin42@gmail.com>
parents:
388
diff
changeset
|
130 if getattr(discovery, 'findcommonoutgoing', None): |
5fdff9b8e742
Cope with new discovery code without crashing.
Augie Fackler <durin42@gmail.com>
parents:
388
diff
changeset
|
131 kwname = 'onlyheads' |
352
7a9d1cc30d61
findoutgoing: more flexible wrapper function that should be more portable
Augie Fackler <durin42@gmail.com>
parents:
351
diff
changeset
|
132 def findoutgoing(orig, local, remote, *args, **kwargs): |
344
af48a5961432
Add just enough code to handle changes to cset discovery.
Augie Fackler <durin42@gmail.com>
parents:
334
diff
changeset
|
133 if isinstance(remote, gitrepo.gitrepo): |
442
553dd7078058
Update for newer dulwich and hg versions.
Augie Fackler <durin42@gmail.com>
parents:
439
diff
changeset
|
134 raise hgutil.Abort( |
553dd7078058
Update for newer dulwich and hg versions.
Augie Fackler <durin42@gmail.com>
parents:
439
diff
changeset
|
135 'hg-git outgoing support is broken') |
414
6867b01d1379
Unbreak outgoing to non-git repos with hg pre-1.9
Brendan Cully <brendan@kublai.com>
parents:
412
diff
changeset
|
136 return orig(local, remote, *args, **kwargs) |
389
5fdff9b8e742
Cope with new discovery code without crashing.
Augie Fackler <durin42@gmail.com>
parents:
388
diff
changeset
|
137 if getattr(discovery, 'findoutgoing', None): |
5fdff9b8e742
Cope with new discovery code without crashing.
Augie Fackler <durin42@gmail.com>
parents:
388
diff
changeset
|
138 extensions.wrapfunction(discovery, 'findoutgoing', findoutgoing) |
5fdff9b8e742
Cope with new discovery code without crashing.
Augie Fackler <durin42@gmail.com>
parents:
388
diff
changeset
|
139 else: |
5fdff9b8e742
Cope with new discovery code without crashing.
Augie Fackler <durin42@gmail.com>
parents:
388
diff
changeset
|
140 extensions.wrapfunction(discovery, 'findcommonoutgoing', |
5fdff9b8e742
Cope with new discovery code without crashing.
Augie Fackler <durin42@gmail.com>
parents:
388
diff
changeset
|
141 findoutgoing) |
344
af48a5961432
Add just enough code to handle changes to cset discovery.
Augie Fackler <durin42@gmail.com>
parents:
334
diff
changeset
|
142 except ImportError: |
af48a5961432
Add just enough code to handle changes to cset discovery.
Augie Fackler <durin42@gmail.com>
parents:
334
diff
changeset
|
143 pass |
af48a5961432
Add just enough code to handle changes to cset discovery.
Augie Fackler <durin42@gmail.com>
parents:
334
diff
changeset
|
144 |
412 | 145 def getremotechanges(orig, ui, repo, other, *args, **opts): |
408 | 146 if isinstance(other, gitrepo.gitrepo): |
424
d2c4333e5f14
getremotechanges: fix incoming support
Augie Fackler <durin42@gmail.com>
parents:
412
diff
changeset
|
147 if args: |
d2c4333e5f14
getremotechanges: fix incoming support
Augie Fackler <durin42@gmail.com>
parents:
412
diff
changeset
|
148 revs = args[0] |
d2c4333e5f14
getremotechanges: fix incoming support
Augie Fackler <durin42@gmail.com>
parents:
412
diff
changeset
|
149 else: |
d2c4333e5f14
getremotechanges: fix incoming support
Augie Fackler <durin42@gmail.com>
parents:
412
diff
changeset
|
150 revs = opts.get('onlyheads', opts.get('revs')) |
408 | 151 git = GitHandler(repo, ui) |
152 r, c, cleanup = git.getremotechanges(other, revs) | |
153 # ugh. This is ugly even by mercurial API compatibility standards | |
154 if 'onlyheads' not in orig.func_code.co_varnames: | |
155 cleanup = None | |
156 return r, c, cleanup | |
412 | 157 return orig(ui, repo, other, *args, **opts) |
408 | 158 try: |
159 extensions.wrapfunction(bundlerepo, 'getremotechanges', getremotechanges) | |
160 except AttributeError: | |
161 # 1.7+ | |
162 pass | |
163 | |
0
06366111af3c
initial import of the hg-git bridging extension for mercurial
Scott Chacon <schacon@gmail.com>
parents:
diff
changeset
|
164 cmdtable = { |
137
5aefcbf1e50c
add a gimport command
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
136
diff
changeset
|
165 "gimport": |
5aefcbf1e50c
add a gimport command
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
136
diff
changeset
|
166 (gimport, [], _('hg gimport')), |
97 | 167 "gexport": |
168 (gexport, [], _('hg gexport')), | |
40
f5b000ec7100
added gclear command to remove all the git data
Scott Chacon <schacon@gmail.com>
parents:
39
diff
changeset
|
169 "gclear": |
f5b000ec7100
added gclear command to remove all the git data
Scott Chacon <schacon@gmail.com>
parents:
39
diff
changeset
|
170 (gclear, [], _('Clears out the Git cached data')), |
298
6ad6945b6629
pull: make it possible to un-wedge the repo after stripping git revs
Augie Fackler <durin42@gmail.com>
parents:
297
diff
changeset
|
171 "git-cleanup": (git_cleanup, [], _( |
6ad6945b6629
pull: make it possible to un-wedge the repo after stripping git revs
Augie Fackler <durin42@gmail.com>
parents:
297
diff
changeset
|
172 "Cleans up git repository after history editing")) |
182
9bdd8e76bbab
Remove remotes support (use the paths section in hgrc instead)
Abderrahim Kitouni <a.kitouni@gmail.com>
parents:
180
diff
changeset
|
173 } |