Mercurial > hg-git
annotate hggit/__init__.py @ 909:67b27ec080ae
ignore: evaluate ignore.readpats to see if ignore module really exists
Otherwise ImportError wouldn't be raised thanks to demandimport.
Perhaps tests passed at e5b10a710036 because we are likely to have ignore.pyc
in our mercurial tree.
author | Yuya Nishihara <yuya@tcha.org> |
---|---|
date | Sun, 31 May 2015 13:51:42 +0900 |
parents | e5b10a710036 |
children | 5cc9594cc811 |
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:// |
481
9df1741f3977
help: add additional help topics
David M. Carr <david@carrclan.us>
parents:
442
diff
changeset
|
16 |
9df1741f3977
help: add additional help topics
David M. Carr <david@carrclan.us>
parents:
442
diff
changeset
|
17 For more information and instructions, see :hg:`help git` |
0
06366111af3c
initial import of the hg-git bridging extension for mercurial
Scott Chacon <schacon@gmail.com>
parents:
diff
changeset
|
18 ''' |
06366111af3c
initial import of the hg-git bridging extension for mercurial
Scott Chacon <schacon@gmail.com>
parents:
diff
changeset
|
19 |
481
9df1741f3977
help: add additional help topics
David M. Carr <david@carrclan.us>
parents:
442
diff
changeset
|
20 from bisect import insort |
256
442fe2ca104d
Simpler handling of detection of git repos
Mads Kiilerich <mads@kiilerich.com>
parents:
220
diff
changeset
|
21 import os |
442fe2ca104d
Simpler handling of detection of git repos
Mads Kiilerich <mads@kiilerich.com>
parents:
220
diff
changeset
|
22 |
408 | 23 from mercurial import bundlerepo |
732
a67fecf02adb
commands: switch to new-style declaration via decorators
Siddharth Agarwal <sid0@fb.com>
parents:
731
diff
changeset
|
24 from mercurial import cmdutil |
362
5b6961384ee2
demandimport: defend against collections breakage in new dulwich
Augie Fackler <durin42@gmail.com>
parents:
352
diff
changeset
|
25 from mercurial import demandimport |
615
503d403fc040
Fix for #68 | Use .gitignore files (with proper semantics)
Ben Kehoe <benk@berkeley.edu>
parents:
556
diff
changeset
|
26 from mercurial import dirstate |
523
8c1f2b07c04b
outgoing: re-introduce support for outgoing
David M. Carr <david@carrclan.us>
parents:
483
diff
changeset
|
27 from mercurial import discovery |
782
e5450a81676e
__init__: work around exchange not yet existing in hg 2.8.x
Augie Fackler <raf@durin42.com>
parents:
781
diff
changeset
|
28 try: |
e5450a81676e
__init__: work around exchange not yet existing in hg 2.8.x
Augie Fackler <raf@durin42.com>
parents:
781
diff
changeset
|
29 from mercurial import exchange |
887
8f9d52f7942e
init: whitespace and formating cleanup
Sean Farley <sean@farley.io>
parents:
857
diff
changeset
|
30 exchange.push # existed in first iteration of this file |
782
e5450a81676e
__init__: work around exchange not yet existing in hg 2.8.x
Augie Fackler <raf@durin42.com>
parents:
781
diff
changeset
|
31 except ImportError: |
e5450a81676e
__init__: work around exchange not yet existing in hg 2.8.x
Augie Fackler <raf@durin42.com>
parents:
781
diff
changeset
|
32 # We only *use* the exchange module in hg 3.2+, so this is safe |
e5450a81676e
__init__: work around exchange not yet existing in hg 2.8.x
Augie Fackler <raf@durin42.com>
parents:
781
diff
changeset
|
33 pass |
334
eb345bacc1da
Cope with tags being sorted (hg cset c7dbd6c4877a) by backporting that behavior
Augie Fackler <durin42@gmail.com>
parents:
320
diff
changeset
|
34 from mercurial import extensions |
481
9df1741f3977
help: add additional help topics
David M. Carr <david@carrclan.us>
parents:
442
diff
changeset
|
35 from mercurial import help |
334
eb345bacc1da
Cope with tags being sorted (hg cset c7dbd6c4877a) by backporting that behavior
Augie Fackler <durin42@gmail.com>
parents:
320
diff
changeset
|
36 from mercurial import hg |
907
e5b10a710036
ignore: update ignore logic to match upstream
Durham Goode <durham@fb.com>
parents:
901
diff
changeset
|
37 try: |
e5b10a710036
ignore: update ignore logic to match upstream
Durham Goode <durham@fb.com>
parents:
901
diff
changeset
|
38 from mercurial import ignore |
909
67b27ec080ae
ignore: evaluate ignore.readpats to see if ignore module really exists
Yuya Nishihara <yuya@tcha.org>
parents:
907
diff
changeset
|
39 ignore.readpats |
907
e5b10a710036
ignore: update ignore logic to match upstream
Durham Goode <durham@fb.com>
parents:
901
diff
changeset
|
40 ignoremod = True |
e5b10a710036
ignore: update ignore logic to match upstream
Durham Goode <durham@fb.com>
parents:
901
diff
changeset
|
41 except ImportError: |
e5b10a710036
ignore: update ignore logic to match upstream
Durham Goode <durham@fb.com>
parents:
901
diff
changeset
|
42 # The ignore module disappeared in Mercurial 3.5 |
e5b10a710036
ignore: update ignore logic to match upstream
Durham Goode <durham@fb.com>
parents:
901
diff
changeset
|
43 ignoremod = False |
334
eb345bacc1da
Cope with tags being sorted (hg cset c7dbd6c4877a) by backporting that behavior
Augie Fackler <durin42@gmail.com>
parents:
320
diff
changeset
|
44 from mercurial import localrepo |
899
11ca21820a95
overlay: adapt diff to work with lazymanifests
Siddharth Agarwal <sid0@fb.com>
parents:
897
diff
changeset
|
45 from mercurial import manifest |
713
96f0463a4e54
revset_gitnode: use repo.changelog.node instead of contexts
Siddharth Agarwal <sid0@fb.com>
parents:
706
diff
changeset
|
46 from mercurial.node import hex |
483
d2caea269670
revsets: add fromgit and gitnode selectors
David M. Carr <david@carrclan.us>
parents:
482
diff
changeset
|
47 from mercurial import revset |
731
705f0a2a7c18
verify: add a wrapper function in __init__.py
Siddharth Agarwal <sid0@fb.com>
parents:
730
diff
changeset
|
48 from mercurial import scmutil |
482
00d591868a2f
templatekw: add support for gitnode template keyword
David M. Carr <david@carrclan.us>
parents:
481
diff
changeset
|
49 from mercurial import templatekw |
334
eb345bacc1da
Cope with tags being sorted (hg cset c7dbd6c4877a) by backporting that behavior
Augie Fackler <durin42@gmail.com>
parents:
320
diff
changeset
|
50 from mercurial import util as hgutil |
0
06366111af3c
initial import of the hg-git bridging extension for mercurial
Scott Chacon <schacon@gmail.com>
parents:
diff
changeset
|
51 from mercurial.i18n import _ |
220
211fa793d74f
support local git repositories (fixes issue 5 bb)
Abderrahim Kitouni <a.kitouni@gmail.com>
parents:
210
diff
changeset
|
52 |
887
8f9d52f7942e
init: whitespace and formating cleanup
Sean Farley <sean@farley.io>
parents:
857
diff
changeset
|
53 import gitrepo |
8f9d52f7942e
init: whitespace and formating cleanup
Sean Farley <sean@farley.io>
parents:
857
diff
changeset
|
54 import hgrepo |
899
11ca21820a95
overlay: adapt diff to work with lazymanifests
Siddharth Agarwal <sid0@fb.com>
parents:
897
diff
changeset
|
55 import overlay |
887
8f9d52f7942e
init: whitespace and formating cleanup
Sean Farley <sean@farley.io>
parents:
857
diff
changeset
|
56 import util |
8f9d52f7942e
init: whitespace and formating cleanup
Sean Farley <sean@farley.io>
parents:
857
diff
changeset
|
57 from git_handler import GitHandler |
8f9d52f7942e
init: whitespace and formating cleanup
Sean Farley <sean@farley.io>
parents:
857
diff
changeset
|
58 import verify |
8f9d52f7942e
init: whitespace and formating cleanup
Sean Farley <sean@farley.io>
parents:
857
diff
changeset
|
59 |
362
5b6961384ee2
demandimport: defend against collections breakage in new dulwich
Augie Fackler <durin42@gmail.com>
parents:
352
diff
changeset
|
60 demandimport.ignore.extend([ |
5b6961384ee2
demandimport: defend against collections breakage in new dulwich
Augie Fackler <durin42@gmail.com>
parents:
352
diff
changeset
|
61 'collections', |
887
8f9d52f7942e
init: whitespace and formating cleanup
Sean Farley <sean@farley.io>
parents:
857
diff
changeset
|
62 ]) |
0
06366111af3c
initial import of the hg-git bridging extension for mercurial
Scott Chacon <schacon@gmail.com>
parents:
diff
changeset
|
63 |
901
49831f78c412
init: mark hg-git as compatible with Mercurial 3.4
Siddharth Agarwal <sid0@fb.com>
parents:
899
diff
changeset
|
64 testedwith = '2.8.2 3.0.1 3.1 3.2.2 3.3 3.4' |
545 | 65 buglink = 'https://bitbucket.org/durin42/hg-git/issues' |
66 | |
732
a67fecf02adb
commands: switch to new-style declaration via decorators
Siddharth Agarwal <sid0@fb.com>
parents:
731
diff
changeset
|
67 cmdtable = {} |
a67fecf02adb
commands: switch to new-style declaration via decorators
Siddharth Agarwal <sid0@fb.com>
parents:
731
diff
changeset
|
68 command = cmdutil.command(cmdtable) |
a67fecf02adb
commands: switch to new-style declaration via decorators
Siddharth Agarwal <sid0@fb.com>
parents:
731
diff
changeset
|
69 |
60
05a96f7750ad
add support for `hg clone git://github.com/defunkt/facebox.git`
Chris Wanstrath <chris@ozmm.org>
parents:
59
diff
changeset
|
70 # 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
|
71 # 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
|
72 _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
|
73 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
|
74 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
|
75 |
256
442fe2ca104d
Simpler handling of detection of git repos
Mads Kiilerich <mads@kiilerich.com>
parents:
220
diff
changeset
|
76 # 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
|
77 _oldlocal = hg.schemes['file'] |
211fa793d74f
support local git repositories (fixes issue 5 bb)
Abderrahim Kitouni <a.kitouni@gmail.com>
parents:
210
diff
changeset
|
78 |
388
bcc79fa3fe09
url wasn't ever published as url.url, and is now util.url
Augie Fackler <durin42@gmail.com>
parents:
383
diff
changeset
|
79 try: |
bcc79fa3fe09
url wasn't ever published as url.url, and is now util.url
Augie Fackler <durin42@gmail.com>
parents:
383
diff
changeset
|
80 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
|
81 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
|
82 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
|
83 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
|
84 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
|
85 |
bcc79fa3fe09
url wasn't ever published as url.url, and is now util.url
Augie Fackler <durin42@gmail.com>
parents:
383
diff
changeset
|
86 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
|
87 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
|
88 |
220
211fa793d74f
support local git repositories (fixes issue 5 bb)
Abderrahim Kitouni <a.kitouni@gmail.com>
parents:
210
diff
changeset
|
89 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
|
90 p = urlcls(path).localpath() |
280 | 91 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
|
92 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
|
93 return gitrepo |
263
9f5a7a5d52aa
Enable detection of bare repositories as a local git repo
Lincoln Stoll <lstoll@lstoll.net>
parents:
260
diff
changeset
|
94 # detect a bare repository |
280 | 95 if (os.path.exists(os.path.join(p, 'HEAD')) and |
96 os.path.exists(os.path.join(p, 'objects')) and | |
97 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
|
98 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
|
99 return gitrepo |
256
442fe2ca104d
Simpler handling of detection of git repos
Mads Kiilerich <mads@kiilerich.com>
parents:
220
diff
changeset
|
100 return _oldlocal(path) |
220
211fa793d74f
support local git repositories (fixes issue 5 bb)
Abderrahim Kitouni <a.kitouni@gmail.com>
parents:
210
diff
changeset
|
101 |
211fa793d74f
support local git repositories (fixes issue 5 bb)
Abderrahim Kitouni <a.kitouni@gmail.com>
parents:
210
diff
changeset
|
102 hg.schemes['file'] = _local |
211fa793d74f
support local git repositories (fixes issue 5 bb)
Abderrahim Kitouni <a.kitouni@gmail.com>
parents:
210
diff
changeset
|
103 |
281
a14529b7b8f2
init: strip .git for default clone destination for git sources
Augie Fackler <durin42@gmail.com>
parents:
280
diff
changeset
|
104 hgdefaultdest = hg.defaultdest |
a14529b7b8f2
init: strip .git for default clone destination for git sources
Augie Fackler <durin42@gmail.com>
parents:
280
diff
changeset
|
105 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
|
106 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
|
107 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
|
108 source = source[:-4] |
a14529b7b8f2
init: strip .git for default clone destination for git sources
Augie Fackler <durin42@gmail.com>
parents:
280
diff
changeset
|
109 break |
a14529b7b8f2
init: strip .git for default clone destination for git sources
Augie Fackler <durin42@gmail.com>
parents:
280
diff
changeset
|
110 return hgdefaultdest(source) |
a14529b7b8f2
init: strip .git for default clone destination for git sources
Augie Fackler <durin42@gmail.com>
parents:
280
diff
changeset
|
111 hg.defaultdest = defaultdest |
a14529b7b8f2
init: strip .git for default clone destination for git sources
Augie Fackler <durin42@gmail.com>
parents:
280
diff
changeset
|
112 |
297
a90fe3e8a8c3
hggit: defend against exceptions when pulling with -r
Augie Fackler <durin42@gmail.com>
parents:
296
diff
changeset
|
113 # 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
|
114 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
|
115 revs, co = orig(lrepo, repo, branches, revs) |
706
5e74edb7a62d
safebranchrevs: handle changelog having no commits
Siddharth Agarwal <sid0@fb.com>
parents:
695
diff
changeset
|
116 if hgutil.safehasattr(lrepo, 'changelog') and co not in lrepo.changelog: |
297
a90fe3e8a8c3
hggit: defend against exceptions when pulling with -r
Augie Fackler <durin42@gmail.com>
parents:
296
diff
changeset
|
117 co = None |
a90fe3e8a8c3
hggit: defend against exceptions when pulling with -r
Augie Fackler <durin42@gmail.com>
parents:
296
diff
changeset
|
118 return revs, co |
300
eec31dee258e
Various hg 1.4 compat fixes.
Augie Fackler <durin42@gmail.com>
parents:
298
diff
changeset
|
119 if getattr(hg, 'addbranchrevs', False): |
eec31dee258e
Various hg 1.4 compat fixes.
Augie Fackler <durin42@gmail.com>
parents:
298
diff
changeset
|
120 extensions.wrapfunction(hg, 'addbranchrevs', safebranchrevs) |
297
a90fe3e8a8c3
hggit: defend against exceptions when pulling with -r
Augie Fackler <durin42@gmail.com>
parents:
296
diff
changeset
|
121 |
695
2c67099875cd
extsetup: use new-style extsetup with ui parameter
Siddharth Agarwal <sid0@fb.com>
parents:
693
diff
changeset
|
122 def extsetup(ui): |
482
00d591868a2f
templatekw: add support for gitnode template keyword
David M. Carr <david@carrclan.us>
parents:
481
diff
changeset
|
123 templatekw.keywords.update({'gitnode': gitnodekw}) |
483
d2caea269670
revsets: add fromgit and gitnode selectors
David M. Carr <david@carrclan.us>
parents:
482
diff
changeset
|
124 revset.symbols.update({ |
d2caea269670
revsets: add fromgit and gitnode selectors
David M. Carr <david@carrclan.us>
parents:
482
diff
changeset
|
125 'fromgit': revset_fromgit, 'gitnode': revset_gitnode |
d2caea269670
revsets: add fromgit and gitnode selectors
David M. Carr <david@carrclan.us>
parents:
482
diff
changeset
|
126 }) |
481
9df1741f3977
help: add additional help topics
David M. Carr <david@carrclan.us>
parents:
442
diff
changeset
|
127 helpdir = os.path.join(os.path.dirname(__file__), 'help') |
9df1741f3977
help: add additional help topics
David M. Carr <david@carrclan.us>
parents:
442
diff
changeset
|
128 entry = (['git'], _("Working with Git Repositories"), |
887
8f9d52f7942e
init: whitespace and formating cleanup
Sean Farley <sean@farley.io>
parents:
857
diff
changeset
|
129 lambda: open(os.path.join(helpdir, 'git.rst')).read()) |
675
4cb3515cefb0
extsetup: drop support for Mercurial < 1.7
Siddharth Agarwal <sid0@fb.com>
parents:
674
diff
changeset
|
130 insort(help.helptable, entry) |
481
9df1741f3977
help: add additional help topics
David M. Carr <david@carrclan.us>
parents:
442
diff
changeset
|
131 |
206
5986ac6a591e
create the repository subclass in reposetup
Abderrahim Kitouni <a.kitouni@gmail.com>
parents:
182
diff
changeset
|
132 def reposetup(ui, repo): |
296
32456f9cb7a4
hggit: don't wrap gitrepo with hgrepo
Augie Fackler <durin42@gmail.com>
parents:
281
diff
changeset
|
133 if not isinstance(repo, gitrepo.gitrepo): |
32456f9cb7a4
hggit: don't wrap gitrepo with hgrepo
Augie Fackler <durin42@gmail.com>
parents:
281
diff
changeset
|
134 klass = hgrepo.generate_repo_subclass(repo.__class__) |
32456f9cb7a4
hggit: don't wrap gitrepo with hgrepo
Augie Fackler <durin42@gmail.com>
parents:
281
diff
changeset
|
135 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
|
136 |
899
11ca21820a95
overlay: adapt diff to work with lazymanifests
Siddharth Agarwal <sid0@fb.com>
parents:
897
diff
changeset
|
137 if hgutil.safehasattr(manifest, '_lazymanifest'): |
11ca21820a95
overlay: adapt diff to work with lazymanifests
Siddharth Agarwal <sid0@fb.com>
parents:
897
diff
changeset
|
138 # Mercurial >= 3.4 |
11ca21820a95
overlay: adapt diff to work with lazymanifests
Siddharth Agarwal <sid0@fb.com>
parents:
897
diff
changeset
|
139 extensions.wrapfunction(manifest.manifestdict, 'diff', |
11ca21820a95
overlay: adapt diff to work with lazymanifests
Siddharth Agarwal <sid0@fb.com>
parents:
897
diff
changeset
|
140 overlay.wrapmanifestdictdiff) |
11ca21820a95
overlay: adapt diff to work with lazymanifests
Siddharth Agarwal <sid0@fb.com>
parents:
897
diff
changeset
|
141 |
733
5e53342c846b
gimport: drop empty options and redundant synopsis, and add help text
Siddharth Agarwal <sid0@fb.com>
parents:
732
diff
changeset
|
142 @command('gimport') |
137
5aefcbf1e50c
add a gimport command
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
136
diff
changeset
|
143 def gimport(ui, repo, remote_name=None): |
733
5e53342c846b
gimport: drop empty options and redundant synopsis, and add help text
Siddharth Agarwal <sid0@fb.com>
parents:
732
diff
changeset
|
144 '''import commits from Git to Mercurial''' |
663
ad0d90fa7a4f
gimport: use githandler from repo
Siddharth Agarwal <sid0@fb.com>
parents:
624
diff
changeset
|
145 repo.githandler.import_commits(remote_name) |
137
5aefcbf1e50c
add a gimport command
Sverre Rabbelier <sverre@rabbelier.nl>
parents:
136
diff
changeset
|
146 |
734
351213785c4a
gexport: drop empty options and redundant synopsis, and add help text
Siddharth Agarwal <sid0@fb.com>
parents:
733
diff
changeset
|
147 @command('gexport') |
97 | 148 def gexport(ui, repo): |
734
351213785c4a
gexport: drop empty options and redundant synopsis, and add help text
Siddharth Agarwal <sid0@fb.com>
parents:
733
diff
changeset
|
149 '''export commits from Mercurial to Git''' |
664
570c3702b916
gexport: use githandler from repo
Siddharth Agarwal <sid0@fb.com>
parents:
663
diff
changeset
|
150 repo.githandler.export_commits() |
97 | 151 |
735
b48be97bd6fd
gclear: drop empty options and move help text to docstring
Siddharth Agarwal <sid0@fb.com>
parents:
734
diff
changeset
|
152 @command('gclear') |
40
f5b000ec7100
added gclear command to remove all the git data
Scott Chacon <schacon@gmail.com>
parents:
39
diff
changeset
|
153 def gclear(ui, repo): |
735
b48be97bd6fd
gclear: drop empty options and move help text to docstring
Siddharth Agarwal <sid0@fb.com>
parents:
734
diff
changeset
|
154 '''clear out the Git cached data''' |
40
f5b000ec7100
added gclear command to remove all the git data
Scott Chacon <schacon@gmail.com>
parents:
39
diff
changeset
|
155 repo.ui.status(_("clearing out the git cache data\n")) |
665
2659f63f0beb
gclear: use githandler from repo
Siddharth Agarwal <sid0@fb.com>
parents:
664
diff
changeset
|
156 repo.githandler.clear() |
622
6faa5b0f8909
gitignore: gate feature on dirstate having rootcache and ignore having readpats
Augie Fackler <raf@durin42.com>
parents:
615
diff
changeset
|
157 |
732
a67fecf02adb
commands: switch to new-style declaration via decorators
Siddharth Agarwal <sid0@fb.com>
parents:
731
diff
changeset
|
158 @command('gverify', |
a67fecf02adb
commands: switch to new-style declaration via decorators
Siddharth Agarwal <sid0@fb.com>
parents:
731
diff
changeset
|
159 [('r', 'rev', '', _('revision to verify'), _('REV'))], |
a67fecf02adb
commands: switch to new-style declaration via decorators
Siddharth Agarwal <sid0@fb.com>
parents:
731
diff
changeset
|
160 _('[-r REV]')) |
731
705f0a2a7c18
verify: add a wrapper function in __init__.py
Siddharth Agarwal <sid0@fb.com>
parents:
730
diff
changeset
|
161 def gverify(ui, repo, **opts): |
705f0a2a7c18
verify: add a wrapper function in __init__.py
Siddharth Agarwal <sid0@fb.com>
parents:
730
diff
changeset
|
162 '''verify that a Mercurial rev matches the corresponding Git rev |
705f0a2a7c18
verify: add a wrapper function in __init__.py
Siddharth Agarwal <sid0@fb.com>
parents:
730
diff
changeset
|
163 |
705f0a2a7c18
verify: add a wrapper function in __init__.py
Siddharth Agarwal <sid0@fb.com>
parents:
730
diff
changeset
|
164 Given a Mercurial revision that has a corresponding Git revision in the map, |
705f0a2a7c18
verify: add a wrapper function in __init__.py
Siddharth Agarwal <sid0@fb.com>
parents:
730
diff
changeset
|
165 this attempts to answer whether that revision has the same contents as the |
705f0a2a7c18
verify: add a wrapper function in __init__.py
Siddharth Agarwal <sid0@fb.com>
parents:
730
diff
changeset
|
166 corresponding Git revision. |
705f0a2a7c18
verify: add a wrapper function in __init__.py
Siddharth Agarwal <sid0@fb.com>
parents:
730
diff
changeset
|
167 |
705f0a2a7c18
verify: add a wrapper function in __init__.py
Siddharth Agarwal <sid0@fb.com>
parents:
730
diff
changeset
|
168 ''' |
705f0a2a7c18
verify: add a wrapper function in __init__.py
Siddharth Agarwal <sid0@fb.com>
parents:
730
diff
changeset
|
169 ctx = scmutil.revsingle(repo, opts.get('rev'), '.') |
705f0a2a7c18
verify: add a wrapper function in __init__.py
Siddharth Agarwal <sid0@fb.com>
parents:
730
diff
changeset
|
170 return verify.verify(ui, repo, ctx) |
705f0a2a7c18
verify: add a wrapper function in __init__.py
Siddharth Agarwal <sid0@fb.com>
parents:
730
diff
changeset
|
171 |
622
6faa5b0f8909
gitignore: gate feature on dirstate having rootcache and ignore having readpats
Augie Fackler <raf@durin42.com>
parents:
615
diff
changeset
|
172 if (getattr(dirstate, 'rootcache', False) and |
907
e5b10a710036
ignore: update ignore logic to match upstream
Durham Goode <durham@fb.com>
parents:
901
diff
changeset
|
173 (not ignoremod or getattr(ignore, 'readpats', False))): |
622
6faa5b0f8909
gitignore: gate feature on dirstate having rootcache and ignore having readpats
Augie Fackler <raf@durin42.com>
parents:
615
diff
changeset
|
174 # only install our dirstate wrapper if it has a hope of working |
6faa5b0f8909
gitignore: gate feature on dirstate having rootcache and ignore having readpats
Augie Fackler <raf@durin42.com>
parents:
615
diff
changeset
|
175 import gitdirstate |
907
e5b10a710036
ignore: update ignore logic to match upstream
Durham Goode <durham@fb.com>
parents:
901
diff
changeset
|
176 if ignoremod: |
e5b10a710036
ignore: update ignore logic to match upstream
Durham Goode <durham@fb.com>
parents:
901
diff
changeset
|
177 def ignorewrap(orig, *args, **kwargs): |
e5b10a710036
ignore: update ignore logic to match upstream
Durham Goode <durham@fb.com>
parents:
901
diff
changeset
|
178 return gitdirstate.gignore(*args, **kwargs) |
e5b10a710036
ignore: update ignore logic to match upstream
Durham Goode <durham@fb.com>
parents:
901
diff
changeset
|
179 extensions.wrapfunction(ignore, 'ignore', ignorewrap) |
622
6faa5b0f8909
gitignore: gate feature on dirstate having rootcache and ignore having readpats
Augie Fackler <raf@durin42.com>
parents:
615
diff
changeset
|
180 dirstate.dirstate = gitdirstate.gitdirstate |
59
19d714ee9941
gfetch should access repo when printing, not dest_repo
Chris Wanstrath <chris@ozmm.org>
parents:
40
diff
changeset
|
181 |
736
5d35a5c12b02
git-cleanup: drop empty options and move help text to docstring
Siddharth Agarwal <sid0@fb.com>
parents:
735
diff
changeset
|
182 @command('git-cleanup') |
298
6ad6945b6629
pull: make it possible to un-wedge the repo after stripping git revs
Augie Fackler <durin42@gmail.com>
parents:
297
diff
changeset
|
183 def git_cleanup(ui, repo): |
736
5d35a5c12b02
git-cleanup: drop empty options and move help text to docstring
Siddharth Agarwal <sid0@fb.com>
parents:
735
diff
changeset
|
184 '''clean up Git commit map after history editing''' |
298
6ad6945b6629
pull: make it possible to un-wedge the repo after stripping git revs
Augie Fackler <durin42@gmail.com>
parents:
297
diff
changeset
|
185 new_map = [] |
768
4a9057b16f40
git_handler: rename mapfile to map_file for PEP8 compat
Siddharth Agarwal <sid0@fb.com>
parents:
754
diff
changeset
|
186 for line in repo.opener(GitHandler.map_file): |
298
6ad6945b6629
pull: make it possible to un-wedge the repo after stripping git revs
Augie Fackler <durin42@gmail.com>
parents:
297
diff
changeset
|
187 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
|
188 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
|
189 new_map.append('%s %s\n' % (gitsha, hgsha)) |
768
4a9057b16f40
git_handler: rename mapfile to map_file for PEP8 compat
Siddharth Agarwal <sid0@fb.com>
parents:
754
diff
changeset
|
190 f = repo.opener(GitHandler.map_file, 'wb') |
298
6ad6945b6629
pull: make it possible to un-wedge the repo after stripping git revs
Augie Fackler <durin42@gmail.com>
parents:
297
diff
changeset
|
191 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
|
192 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
|
193 |
523
8c1f2b07c04b
outgoing: re-introduce support for outgoing
David M. Carr <david@carrclan.us>
parents:
483
diff
changeset
|
194 def findcommonoutgoing(orig, repo, other, *args, **kwargs): |
8c1f2b07c04b
outgoing: re-introduce support for outgoing
David M. Carr <david@carrclan.us>
parents:
483
diff
changeset
|
195 if isinstance(other, gitrepo.gitrepo): |
666
27fefb7e7cec
findcommonoutgoing: use githandler from repo
Siddharth Agarwal <sid0@fb.com>
parents:
665
diff
changeset
|
196 heads = repo.githandler.get_refs(other.path)[0] |
523
8c1f2b07c04b
outgoing: re-introduce support for outgoing
David M. Carr <david@carrclan.us>
parents:
483
diff
changeset
|
197 kw = {} |
8c1f2b07c04b
outgoing: re-introduce support for outgoing
David M. Carr <david@carrclan.us>
parents:
483
diff
changeset
|
198 kw.update(kwargs) |
8c1f2b07c04b
outgoing: re-introduce support for outgoing
David M. Carr <david@carrclan.us>
parents:
483
diff
changeset
|
199 for val, k in zip(args, |
887
8f9d52f7942e
init: whitespace and formating cleanup
Sean Farley <sean@farley.io>
parents:
857
diff
changeset
|
200 ('onlyheads', 'force', 'commoninc', 'portable')): |
523
8c1f2b07c04b
outgoing: re-introduce support for outgoing
David M. Carr <david@carrclan.us>
parents:
483
diff
changeset
|
201 kw[k] = val |
8c1f2b07c04b
outgoing: re-introduce support for outgoing
David M. Carr <david@carrclan.us>
parents:
483
diff
changeset
|
202 force = kw.get('force', False) |
8c1f2b07c04b
outgoing: re-introduce support for outgoing
David M. Carr <david@carrclan.us>
parents:
483
diff
changeset
|
203 commoninc = kw.get('commoninc', None) |
8c1f2b07c04b
outgoing: re-introduce support for outgoing
David M. Carr <david@carrclan.us>
parents:
483
diff
changeset
|
204 if commoninc is None: |
887
8f9d52f7942e
init: whitespace and formating cleanup
Sean Farley <sean@farley.io>
parents:
857
diff
changeset
|
205 commoninc = discovery.findcommonincoming(repo, other, heads=heads, |
8f9d52f7942e
init: whitespace and formating cleanup
Sean Farley <sean@farley.io>
parents:
857
diff
changeset
|
206 force=force) |
523
8c1f2b07c04b
outgoing: re-introduce support for outgoing
David M. Carr <david@carrclan.us>
parents:
483
diff
changeset
|
207 kw['commoninc'] = commoninc |
8c1f2b07c04b
outgoing: re-introduce support for outgoing
David M. Carr <david@carrclan.us>
parents:
483
diff
changeset
|
208 return orig(repo, other, **kw) |
8c1f2b07c04b
outgoing: re-introduce support for outgoing
David M. Carr <david@carrclan.us>
parents:
483
diff
changeset
|
209 return orig(repo, other, *args, **kwargs) |
8c1f2b07c04b
outgoing: re-introduce support for outgoing
David M. Carr <david@carrclan.us>
parents:
483
diff
changeset
|
210 extensions.wrapfunction(discovery, 'findcommonoutgoing', findcommonoutgoing) |
344
af48a5961432
Add just enough code to handle changes to cset discovery.
Augie Fackler <durin42@gmail.com>
parents:
334
diff
changeset
|
211 |
412 | 212 def getremotechanges(orig, ui, repo, other, *args, **opts): |
408 | 213 if isinstance(other, gitrepo.gitrepo): |
424
d2c4333e5f14
getremotechanges: fix incoming support
Augie Fackler <durin42@gmail.com>
parents:
412
diff
changeset
|
214 if args: |
d2c4333e5f14
getremotechanges: fix incoming support
Augie Fackler <durin42@gmail.com>
parents:
412
diff
changeset
|
215 revs = args[0] |
d2c4333e5f14
getremotechanges: fix incoming support
Augie Fackler <durin42@gmail.com>
parents:
412
diff
changeset
|
216 else: |
d2c4333e5f14
getremotechanges: fix incoming support
Augie Fackler <durin42@gmail.com>
parents:
412
diff
changeset
|
217 revs = opts.get('onlyheads', opts.get('revs')) |
667
b5ef3f0e0efe
getremotechanges: use githandler from repo
Siddharth Agarwal <sid0@fb.com>
parents:
666
diff
changeset
|
218 r, c, cleanup = repo.githandler.getremotechanges(other, revs) |
408 | 219 # ugh. This is ugly even by mercurial API compatibility standards |
220 if 'onlyheads' not in orig.func_code.co_varnames: | |
221 cleanup = None | |
222 return r, c, cleanup | |
412 | 223 return orig(ui, repo, other, *args, **opts) |
677
73cf8d292dcb
getremotechanges: drop support for Mercurial < 1.7
Siddharth Agarwal <sid0@fb.com>
parents:
676
diff
changeset
|
224 extensions.wrapfunction(bundlerepo, 'getremotechanges', getremotechanges) |
408 | 225 |
556
affd119533ae
peer: pass localrepo to new gitrepo instances
David M. Carr <david@carrclan.us>
parents:
546
diff
changeset
|
226 def peer(orig, uiorrepo, *args, **opts): |
affd119533ae
peer: pass localrepo to new gitrepo instances
David M. Carr <david@carrclan.us>
parents:
546
diff
changeset
|
227 newpeer = orig(uiorrepo, *args, **opts) |
affd119533ae
peer: pass localrepo to new gitrepo instances
David M. Carr <david@carrclan.us>
parents:
546
diff
changeset
|
228 if isinstance(newpeer, gitrepo.gitrepo): |
affd119533ae
peer: pass localrepo to new gitrepo instances
David M. Carr <david@carrclan.us>
parents:
546
diff
changeset
|
229 if isinstance(uiorrepo, localrepo.localrepository): |
affd119533ae
peer: pass localrepo to new gitrepo instances
David M. Carr <david@carrclan.us>
parents:
546
diff
changeset
|
230 newpeer.localrepo = uiorrepo |
affd119533ae
peer: pass localrepo to new gitrepo instances
David M. Carr <david@carrclan.us>
parents:
546
diff
changeset
|
231 return newpeer |
affd119533ae
peer: pass localrepo to new gitrepo instances
David M. Carr <david@carrclan.us>
parents:
546
diff
changeset
|
232 extensions.wrapfunction(hg, 'peer', peer) |
affd119533ae
peer: pass localrepo to new gitrepo instances
David M. Carr <david@carrclan.us>
parents:
546
diff
changeset
|
233 |
780
db10082cf043
exchange: wrap pull if localrepository.pull isn't available
Siddharth Agarwal <sid0@fb.com>
parents:
768
diff
changeset
|
234 @util.transform_notgit |
db10082cf043
exchange: wrap pull if localrepository.pull isn't available
Siddharth Agarwal <sid0@fb.com>
parents:
768
diff
changeset
|
235 def exchangepull(orig, repo, remote, heads=None, force=False, bookmarks=()): |
db10082cf043
exchange: wrap pull if localrepository.pull isn't available
Siddharth Agarwal <sid0@fb.com>
parents:
768
diff
changeset
|
236 if isinstance(remote, gitrepo.gitrepo): |
841
ef904bd8d3fb
exchangepull: fixup for introduction of transaction manager upstream
Siddharth Agarwal <sid0@fb.com>
parents:
782
diff
changeset
|
237 # transaction manager is present in Mercurial >= 3.3 |
847
05eb0874fa30
init: add a try/except to retain compatibility with Mercurial 3.2
Siddharth Agarwal <sid0@fb.com>
parents:
841
diff
changeset
|
238 try: |
05eb0874fa30
init: add a try/except to retain compatibility with Mercurial 3.2
Siddharth Agarwal <sid0@fb.com>
parents:
841
diff
changeset
|
239 trmanager = getattr(exchange, 'transactionmanager') |
05eb0874fa30
init: add a try/except to retain compatibility with Mercurial 3.2
Siddharth Agarwal <sid0@fb.com>
parents:
841
diff
changeset
|
240 except AttributeError: |
05eb0874fa30
init: add a try/except to retain compatibility with Mercurial 3.2
Siddharth Agarwal <sid0@fb.com>
parents:
841
diff
changeset
|
241 trmanager = None |
780
db10082cf043
exchange: wrap pull if localrepository.pull isn't available
Siddharth Agarwal <sid0@fb.com>
parents:
768
diff
changeset
|
242 pullop = exchange.pulloperation(repo, remote, heads, force, |
db10082cf043
exchange: wrap pull if localrepository.pull isn't available
Siddharth Agarwal <sid0@fb.com>
parents:
768
diff
changeset
|
243 bookmarks=bookmarks) |
841
ef904bd8d3fb
exchangepull: fixup for introduction of transaction manager upstream
Siddharth Agarwal <sid0@fb.com>
parents:
782
diff
changeset
|
244 if trmanager: |
ef904bd8d3fb
exchangepull: fixup for introduction of transaction manager upstream
Siddharth Agarwal <sid0@fb.com>
parents:
782
diff
changeset
|
245 pullop.trmanager = trmanager(repo, 'pull', remote.url()) |
897
8026c094173a
pull: acquire wlock before lock to fix lock-checker warnings
Augie Fackler <raf@durin42.com>
parents:
887
diff
changeset
|
246 wlock = repo.wlock() |
780
db10082cf043
exchange: wrap pull if localrepository.pull isn't available
Siddharth Agarwal <sid0@fb.com>
parents:
768
diff
changeset
|
247 lock = repo.lock() |
db10082cf043
exchange: wrap pull if localrepository.pull isn't available
Siddharth Agarwal <sid0@fb.com>
parents:
768
diff
changeset
|
248 try: |
db10082cf043
exchange: wrap pull if localrepository.pull isn't available
Siddharth Agarwal <sid0@fb.com>
parents:
768
diff
changeset
|
249 pullop.cgresult = repo.githandler.fetch(remote.path, heads) |
841
ef904bd8d3fb
exchangepull: fixup for introduction of transaction manager upstream
Siddharth Agarwal <sid0@fb.com>
parents:
782
diff
changeset
|
250 if trmanager: |
ef904bd8d3fb
exchangepull: fixup for introduction of transaction manager upstream
Siddharth Agarwal <sid0@fb.com>
parents:
782
diff
changeset
|
251 pullop.trmanager.close() |
ef904bd8d3fb
exchangepull: fixup for introduction of transaction manager upstream
Siddharth Agarwal <sid0@fb.com>
parents:
782
diff
changeset
|
252 else: |
ef904bd8d3fb
exchangepull: fixup for introduction of transaction manager upstream
Siddharth Agarwal <sid0@fb.com>
parents:
782
diff
changeset
|
253 pullop.closetransaction() |
780
db10082cf043
exchange: wrap pull if localrepository.pull isn't available
Siddharth Agarwal <sid0@fb.com>
parents:
768
diff
changeset
|
254 return pullop |
db10082cf043
exchange: wrap pull if localrepository.pull isn't available
Siddharth Agarwal <sid0@fb.com>
parents:
768
diff
changeset
|
255 finally: |
841
ef904bd8d3fb
exchangepull: fixup for introduction of transaction manager upstream
Siddharth Agarwal <sid0@fb.com>
parents:
782
diff
changeset
|
256 if trmanager: |
ef904bd8d3fb
exchangepull: fixup for introduction of transaction manager upstream
Siddharth Agarwal <sid0@fb.com>
parents:
782
diff
changeset
|
257 pullop.trmanager.release() |
ef904bd8d3fb
exchangepull: fixup for introduction of transaction manager upstream
Siddharth Agarwal <sid0@fb.com>
parents:
782
diff
changeset
|
258 else: |
ef904bd8d3fb
exchangepull: fixup for introduction of transaction manager upstream
Siddharth Agarwal <sid0@fb.com>
parents:
782
diff
changeset
|
259 pullop.releasetransaction() |
780
db10082cf043
exchange: wrap pull if localrepository.pull isn't available
Siddharth Agarwal <sid0@fb.com>
parents:
768
diff
changeset
|
260 lock.release() |
897
8026c094173a
pull: acquire wlock before lock to fix lock-checker warnings
Augie Fackler <raf@durin42.com>
parents:
887
diff
changeset
|
261 wlock.release() |
780
db10082cf043
exchange: wrap pull if localrepository.pull isn't available
Siddharth Agarwal <sid0@fb.com>
parents:
768
diff
changeset
|
262 else: |
db10082cf043
exchange: wrap pull if localrepository.pull isn't available
Siddharth Agarwal <sid0@fb.com>
parents:
768
diff
changeset
|
263 return orig(repo, remote, heads, force, bookmarks=bookmarks) |
db10082cf043
exchange: wrap pull if localrepository.pull isn't available
Siddharth Agarwal <sid0@fb.com>
parents:
768
diff
changeset
|
264 if not hgutil.safehasattr(localrepo.localrepository, 'pull'): |
db10082cf043
exchange: wrap pull if localrepository.pull isn't available
Siddharth Agarwal <sid0@fb.com>
parents:
768
diff
changeset
|
265 # Mercurial >= 3.2 |
db10082cf043
exchange: wrap pull if localrepository.pull isn't available
Siddharth Agarwal <sid0@fb.com>
parents:
768
diff
changeset
|
266 extensions.wrapfunction(exchange, 'pull', exchangepull) |
db10082cf043
exchange: wrap pull if localrepository.pull isn't available
Siddharth Agarwal <sid0@fb.com>
parents:
768
diff
changeset
|
267 |
781
8bfb1d72b49c
exchange: wrap push if localrepository.push isn't available
Siddharth Agarwal <sid0@fb.com>
parents:
780
diff
changeset
|
268 # TODO figure out something useful to do with the newbranch param |
8bfb1d72b49c
exchange: wrap push if localrepository.push isn't available
Siddharth Agarwal <sid0@fb.com>
parents:
780
diff
changeset
|
269 @util.transform_notgit |
8bfb1d72b49c
exchange: wrap push if localrepository.push isn't available
Siddharth Agarwal <sid0@fb.com>
parents:
780
diff
changeset
|
270 def exchangepush(orig, repo, remote, force=False, revs=None, newbranch=False, |
8bfb1d72b49c
exchange: wrap push if localrepository.push isn't available
Siddharth Agarwal <sid0@fb.com>
parents:
780
diff
changeset
|
271 bookmarks=()): |
8bfb1d72b49c
exchange: wrap push if localrepository.push isn't available
Siddharth Agarwal <sid0@fb.com>
parents:
780
diff
changeset
|
272 if isinstance(remote, gitrepo.gitrepo): |
8bfb1d72b49c
exchange: wrap push if localrepository.push isn't available
Siddharth Agarwal <sid0@fb.com>
parents:
780
diff
changeset
|
273 pushop = exchange.pushoperation(repo, remote, force, revs, newbranch, |
8bfb1d72b49c
exchange: wrap push if localrepository.push isn't available
Siddharth Agarwal <sid0@fb.com>
parents:
780
diff
changeset
|
274 bookmarks) |
8bfb1d72b49c
exchange: wrap push if localrepository.push isn't available
Siddharth Agarwal <sid0@fb.com>
parents:
780
diff
changeset
|
275 pushop.cgresult = repo.githandler.push(remote.path, revs, force) |
8bfb1d72b49c
exchange: wrap push if localrepository.push isn't available
Siddharth Agarwal <sid0@fb.com>
parents:
780
diff
changeset
|
276 return pushop |
8bfb1d72b49c
exchange: wrap push if localrepository.push isn't available
Siddharth Agarwal <sid0@fb.com>
parents:
780
diff
changeset
|
277 else: |
8bfb1d72b49c
exchange: wrap push if localrepository.push isn't available
Siddharth Agarwal <sid0@fb.com>
parents:
780
diff
changeset
|
278 return orig(repo, remote, force, revs, newbranch, bookmarks=bookmarks) |
8bfb1d72b49c
exchange: wrap push if localrepository.push isn't available
Siddharth Agarwal <sid0@fb.com>
parents:
780
diff
changeset
|
279 if not hgutil.safehasattr(localrepo.localrepository, 'push'): |
8bfb1d72b49c
exchange: wrap push if localrepository.push isn't available
Siddharth Agarwal <sid0@fb.com>
parents:
780
diff
changeset
|
280 # Mercurial >= 3.2 |
8bfb1d72b49c
exchange: wrap push if localrepository.push isn't available
Siddharth Agarwal <sid0@fb.com>
parents:
780
diff
changeset
|
281 extensions.wrapfunction(exchange, 'push', exchangepush) |
8bfb1d72b49c
exchange: wrap push if localrepository.push isn't available
Siddharth Agarwal <sid0@fb.com>
parents:
780
diff
changeset
|
282 |
483
d2caea269670
revsets: add fromgit and gitnode selectors
David M. Carr <david@carrclan.us>
parents:
482
diff
changeset
|
283 def revset_fromgit(repo, subset, x): |
d2caea269670
revsets: add fromgit and gitnode selectors
David M. Carr <david@carrclan.us>
parents:
482
diff
changeset
|
284 '''``fromgit()`` |
d2caea269670
revsets: add fromgit and gitnode selectors
David M. Carr <david@carrclan.us>
parents:
482
diff
changeset
|
285 Select changesets that originate from Git. |
d2caea269670
revsets: add fromgit and gitnode selectors
David M. Carr <david@carrclan.us>
parents:
482
diff
changeset
|
286 ''' |
887
8f9d52f7942e
init: whitespace and formating cleanup
Sean Farley <sean@farley.io>
parents:
857
diff
changeset
|
287 revset.getargs(x, 0, 0, "fromgit takes no arguments") |
668
98e118410521
revset_fromgit: use githandler from repo
Siddharth Agarwal <sid0@fb.com>
parents:
667
diff
changeset
|
288 git = repo.githandler |
714
5770a5a8bc00
revset_fromgit: use repo.changelog.node instead of contexts
Siddharth Agarwal <sid0@fb.com>
parents:
713
diff
changeset
|
289 node = repo.changelog.node |
5770a5a8bc00
revset_fromgit: use repo.changelog.node instead of contexts
Siddharth Agarwal <sid0@fb.com>
parents:
713
diff
changeset
|
290 return [r for r in subset if git.map_git_get(hex(node(r))) is not None] |
483
d2caea269670
revsets: add fromgit and gitnode selectors
David M. Carr <david@carrclan.us>
parents:
482
diff
changeset
|
291 |
d2caea269670
revsets: add fromgit and gitnode selectors
David M. Carr <david@carrclan.us>
parents:
482
diff
changeset
|
292 def revset_gitnode(repo, subset, x): |
d2caea269670
revsets: add fromgit and gitnode selectors
David M. Carr <david@carrclan.us>
parents:
482
diff
changeset
|
293 '''``gitnode(hash)`` |
d2caea269670
revsets: add fromgit and gitnode selectors
David M. Carr <david@carrclan.us>
parents:
482
diff
changeset
|
294 Select changesets that originate in the given Git revision. |
d2caea269670
revsets: add fromgit and gitnode selectors
David M. Carr <david@carrclan.us>
parents:
482
diff
changeset
|
295 ''' |
d2caea269670
revsets: add fromgit and gitnode selectors
David M. Carr <david@carrclan.us>
parents:
482
diff
changeset
|
296 args = revset.getargs(x, 1, 1, "gitnode takes one argument") |
d2caea269670
revsets: add fromgit and gitnode selectors
David M. Carr <david@carrclan.us>
parents:
482
diff
changeset
|
297 rev = revset.getstring(args[0], |
d2caea269670
revsets: add fromgit and gitnode selectors
David M. Carr <david@carrclan.us>
parents:
482
diff
changeset
|
298 "the argument to gitnode() must be a hash") |
669
b8fff2f4e963
revset_gitnode: use githandler from repo
Siddharth Agarwal <sid0@fb.com>
parents:
668
diff
changeset
|
299 git = repo.githandler |
713
96f0463a4e54
revset_gitnode: use repo.changelog.node instead of contexts
Siddharth Agarwal <sid0@fb.com>
parents:
706
diff
changeset
|
300 node = repo.changelog.node |
887
8f9d52f7942e
init: whitespace and formating cleanup
Sean Farley <sean@farley.io>
parents:
857
diff
changeset
|
301 |
483
d2caea269670
revsets: add fromgit and gitnode selectors
David M. Carr <david@carrclan.us>
parents:
482
diff
changeset
|
302 def matches(r): |
713
96f0463a4e54
revset_gitnode: use repo.changelog.node instead of contexts
Siddharth Agarwal <sid0@fb.com>
parents:
706
diff
changeset
|
303 gitnode = git.map_git_get(hex(node(r))) |
483
d2caea269670
revsets: add fromgit and gitnode selectors
David M. Carr <david@carrclan.us>
parents:
482
diff
changeset
|
304 if gitnode is None: |
d2caea269670
revsets: add fromgit and gitnode selectors
David M. Carr <david@carrclan.us>
parents:
482
diff
changeset
|
305 return False |
d2caea269670
revsets: add fromgit and gitnode selectors
David M. Carr <david@carrclan.us>
parents:
482
diff
changeset
|
306 return rev in [gitnode, gitnode[:12]] |
d2caea269670
revsets: add fromgit and gitnode selectors
David M. Carr <david@carrclan.us>
parents:
482
diff
changeset
|
307 return [r for r in subset if matches(r)] |
d2caea269670
revsets: add fromgit and gitnode selectors
David M. Carr <david@carrclan.us>
parents:
482
diff
changeset
|
308 |
482
00d591868a2f
templatekw: add support for gitnode template keyword
David M. Carr <david@carrclan.us>
parents:
481
diff
changeset
|
309 def gitnodekw(**args): |
00d591868a2f
templatekw: add support for gitnode template keyword
David M. Carr <david@carrclan.us>
parents:
481
diff
changeset
|
310 """:gitnode: String. The Git changeset identification hash, as a 40 hexadecimal digit string.""" |
00d591868a2f
templatekw: add support for gitnode template keyword
David M. Carr <david@carrclan.us>
parents:
481
diff
changeset
|
311 node = args['ctx'] |
00d591868a2f
templatekw: add support for gitnode template keyword
David M. Carr <david@carrclan.us>
parents:
481
diff
changeset
|
312 repo = args['repo'] |
670
ab3c64db47d8
gitnodekw: use githandler from repo
Siddharth Agarwal <sid0@fb.com>
parents:
669
diff
changeset
|
313 gitnode = repo.githandler.map_git_get(node.hex()) |
482
00d591868a2f
templatekw: add support for gitnode template keyword
David M. Carr <david@carrclan.us>
parents:
481
diff
changeset
|
314 if gitnode is None: |
00d591868a2f
templatekw: add support for gitnode template keyword
David M. Carr <david@carrclan.us>
parents:
481
diff
changeset
|
315 gitnode = '' |
00d591868a2f
templatekw: add support for gitnode template keyword
David M. Carr <david@carrclan.us>
parents:
481
diff
changeset
|
316 return gitnode |