Mercurial > hgsubversion
annotate hgsubversion/svnrepo.py @ 877:2c9f4c1686fa
svnrepo: don't break on old hg versions that lack pushkey
author | Augie Fackler <raf@durin42.com> |
---|---|
date | Fri, 20 Apr 2012 18:33:39 -0500 |
parents | bb6a013abaed |
children | a103d5211237 |
rev | line source |
---|---|
331
75f082b5897e
Switch to using url scheme wrappers instead of duplicating each command we wrap.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
328
diff
changeset
|
1 """ |
75f082b5897e
Switch to using url scheme wrappers instead of duplicating each command we wrap.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
328
diff
changeset
|
2 repository class-based interface for hgsubversion |
75f082b5897e
Switch to using url scheme wrappers instead of duplicating each command we wrap.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
328
diff
changeset
|
3 |
75f082b5897e
Switch to using url scheme wrappers instead of duplicating each command we wrap.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
328
diff
changeset
|
4 Copyright (C) 2009, Dan Villiom Podlaski Christiansen <danchr@gmail.com> |
75f082b5897e
Switch to using url scheme wrappers instead of duplicating each command we wrap.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
328
diff
changeset
|
5 See parent package for licensing. |
75f082b5897e
Switch to using url scheme wrappers instead of duplicating each command we wrap.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
328
diff
changeset
|
6 |
75f082b5897e
Switch to using url scheme wrappers instead of duplicating each command we wrap.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
328
diff
changeset
|
7 Internally, Mercurial assumes that every single repository is a localrepository |
75f082b5897e
Switch to using url scheme wrappers instead of duplicating each command we wrap.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
328
diff
changeset
|
8 subclass: pull() is called on the instance pull *to*, but not the one pulled |
75f082b5897e
Switch to using url scheme wrappers instead of duplicating each command we wrap.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
328
diff
changeset
|
9 *from*. To work around this, we create two classes: |
75f082b5897e
Switch to using url scheme wrappers instead of duplicating each command we wrap.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
328
diff
changeset
|
10 |
75f082b5897e
Switch to using url scheme wrappers instead of duplicating each command we wrap.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
328
diff
changeset
|
11 - svnremoterepo for Subversion repositories, but it doesn't really do anything. |
75f082b5897e
Switch to using url scheme wrappers instead of duplicating each command we wrap.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
328
diff
changeset
|
12 - svnlocalrepo for local repositories which handles both operations on itself -- |
75f082b5897e
Switch to using url scheme wrappers instead of duplicating each command we wrap.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
328
diff
changeset
|
13 the local, hgsubversion-enabled clone -- and the remote repository. Decorators |
75f082b5897e
Switch to using url scheme wrappers instead of duplicating each command we wrap.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
328
diff
changeset
|
14 are used to distinguish and filter these operations from others. |
75f082b5897e
Switch to using url scheme wrappers instead of duplicating each command we wrap.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
328
diff
changeset
|
15 """ |
75f082b5897e
Switch to using url scheme wrappers instead of duplicating each command we wrap.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
328
diff
changeset
|
16 |
831
be5bbb2f2d68
svnrepo: kludge to work around hash changes between stupid and replay in hg 1.9
Augie Fackler <durin42@gmail.com>
parents:
805
diff
changeset
|
17 import errno |
be5bbb2f2d68
svnrepo: kludge to work around hash changes between stupid and replay in hg 1.9
Augie Fackler <durin42@gmail.com>
parents:
805
diff
changeset
|
18 |
342
76c833526fbc
Use fallbacks in the wrappers for Subversion support, instead of prefixes.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
337
diff
changeset
|
19 from mercurial import error |
326
33736e2e25f0
alternate approach for supporting svn schemes for repository paths
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
158
diff
changeset
|
20 from mercurial import util as hgutil |
342
76c833526fbc
Use fallbacks in the wrappers for Subversion support, instead of prefixes.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
337
diff
changeset
|
21 from mercurial import httprepo |
326
33736e2e25f0
alternate approach for supporting svn schemes for repository paths
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
158
diff
changeset
|
22 import mercurial.repo |
124
291925677a9f
tag_repo: remove gentags command, extend repo.tags(), HgChangeEditor now takes either repo or repo_path
Luke Opperman <luke@loppear.com>
parents:
diff
changeset
|
23 |
858
bb6a013abaed
phases: mark newly created commits from subversion as 'public' to fix #335
Sean Farley <sean@mcs.anl.gov>
parents:
844
diff
changeset
|
24 try: |
bb6a013abaed
phases: mark newly created commits from subversion as 'public' to fix #335
Sean Farley <sean@mcs.anl.gov>
parents:
844
diff
changeset
|
25 from mercurial import phases |
bb6a013abaed
phases: mark newly created commits from subversion as 'public' to fix #335
Sean Farley <sean@mcs.anl.gov>
parents:
844
diff
changeset
|
26 phases.public # defeat demand import |
bb6a013abaed
phases: mark newly created commits from subversion as 'public' to fix #335
Sean Farley <sean@mcs.anl.gov>
parents:
844
diff
changeset
|
27 except ImportError: |
bb6a013abaed
phases: mark newly created commits from subversion as 'public' to fix #335
Sean Farley <sean@mcs.anl.gov>
parents:
844
diff
changeset
|
28 phases = None |
bb6a013abaed
phases: mark newly created commits from subversion as 'public' to fix #335
Sean Farley <sean@mcs.anl.gov>
parents:
844
diff
changeset
|
29 |
844
95d040755254
Added ability to configure the password stores
Jerome M. BERGER <jerome.berger@sagemcom.com>
parents:
831
diff
changeset
|
30 import re |
326
33736e2e25f0
alternate approach for supporting svn schemes for repository paths
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
158
diff
changeset
|
31 import util |
33736e2e25f0
alternate approach for supporting svn schemes for repository paths
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
158
diff
changeset
|
32 import wrappers |
464
0f7095f53ca3
Extend svnrepos with SubversionRepo and SVNMeta
Patrick Mezard <pmezard@gmail.com>
parents:
443
diff
changeset
|
33 import svnwrap |
0f7095f53ca3
Extend svnrepos with SubversionRepo and SVNMeta
Patrick Mezard <pmezard@gmail.com>
parents:
443
diff
changeset
|
34 import svnmeta |
0f7095f53ca3
Extend svnrepos with SubversionRepo and SVNMeta
Patrick Mezard <pmezard@gmail.com>
parents:
443
diff
changeset
|
35 |
0f7095f53ca3
Extend svnrepos with SubversionRepo and SVNMeta
Patrick Mezard <pmezard@gmail.com>
parents:
443
diff
changeset
|
36 propertycache = hgutil.propertycache |
124
291925677a9f
tag_repo: remove gentags command, extend repo.tags(), HgChangeEditor now takes either repo or repo_path
Luke Opperman <luke@loppear.com>
parents:
diff
changeset
|
37 |
831
be5bbb2f2d68
svnrepo: kludge to work around hash changes between stupid and replay in hg 1.9
Augie Fackler <durin42@gmail.com>
parents:
805
diff
changeset
|
38 class ctxctx(object): |
be5bbb2f2d68
svnrepo: kludge to work around hash changes between stupid and replay in hg 1.9
Augie Fackler <durin42@gmail.com>
parents:
805
diff
changeset
|
39 """Proxies a ctx object and ensures files is never empty.""" |
be5bbb2f2d68
svnrepo: kludge to work around hash changes between stupid and replay in hg 1.9
Augie Fackler <durin42@gmail.com>
parents:
805
diff
changeset
|
40 def __init__(self, ctx): |
be5bbb2f2d68
svnrepo: kludge to work around hash changes between stupid and replay in hg 1.9
Augie Fackler <durin42@gmail.com>
parents:
805
diff
changeset
|
41 self._ctx = ctx |
be5bbb2f2d68
svnrepo: kludge to work around hash changes between stupid and replay in hg 1.9
Augie Fackler <durin42@gmail.com>
parents:
805
diff
changeset
|
42 |
be5bbb2f2d68
svnrepo: kludge to work around hash changes between stupid and replay in hg 1.9
Augie Fackler <durin42@gmail.com>
parents:
805
diff
changeset
|
43 def files(self): |
be5bbb2f2d68
svnrepo: kludge to work around hash changes between stupid and replay in hg 1.9
Augie Fackler <durin42@gmail.com>
parents:
805
diff
changeset
|
44 return self._ctx.files() or ['.svn'] |
be5bbb2f2d68
svnrepo: kludge to work around hash changes between stupid and replay in hg 1.9
Augie Fackler <durin42@gmail.com>
parents:
805
diff
changeset
|
45 |
be5bbb2f2d68
svnrepo: kludge to work around hash changes between stupid and replay in hg 1.9
Augie Fackler <durin42@gmail.com>
parents:
805
diff
changeset
|
46 def filectx(self, path, filelog=None): |
be5bbb2f2d68
svnrepo: kludge to work around hash changes between stupid and replay in hg 1.9
Augie Fackler <durin42@gmail.com>
parents:
805
diff
changeset
|
47 if path == '.svn': |
be5bbb2f2d68
svnrepo: kludge to work around hash changes between stupid and replay in hg 1.9
Augie Fackler <durin42@gmail.com>
parents:
805
diff
changeset
|
48 raise IOError(errno.ENOENT, '.svn is a fake file') |
be5bbb2f2d68
svnrepo: kludge to work around hash changes between stupid and replay in hg 1.9
Augie Fackler <durin42@gmail.com>
parents:
805
diff
changeset
|
49 return self._ctx.filectx(path, filelog=filelog) |
be5bbb2f2d68
svnrepo: kludge to work around hash changes between stupid and replay in hg 1.9
Augie Fackler <durin42@gmail.com>
parents:
805
diff
changeset
|
50 |
be5bbb2f2d68
svnrepo: kludge to work around hash changes between stupid and replay in hg 1.9
Augie Fackler <durin42@gmail.com>
parents:
805
diff
changeset
|
51 def __getattr__(self, name): |
be5bbb2f2d68
svnrepo: kludge to work around hash changes between stupid and replay in hg 1.9
Augie Fackler <durin42@gmail.com>
parents:
805
diff
changeset
|
52 return getattr(self._ctx, name) |
be5bbb2f2d68
svnrepo: kludge to work around hash changes between stupid and replay in hg 1.9
Augie Fackler <durin42@gmail.com>
parents:
805
diff
changeset
|
53 |
be5bbb2f2d68
svnrepo: kludge to work around hash changes between stupid and replay in hg 1.9
Augie Fackler <durin42@gmail.com>
parents:
805
diff
changeset
|
54 def __getitem__(self, key): |
be5bbb2f2d68
svnrepo: kludge to work around hash changes between stupid and replay in hg 1.9
Augie Fackler <durin42@gmail.com>
parents:
805
diff
changeset
|
55 return self._ctx[key] |
be5bbb2f2d68
svnrepo: kludge to work around hash changes between stupid and replay in hg 1.9
Augie Fackler <durin42@gmail.com>
parents:
805
diff
changeset
|
56 |
326
33736e2e25f0
alternate approach for supporting svn schemes for repository paths
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
158
diff
changeset
|
57 def generate_repo_class(ui, repo): |
331
75f082b5897e
Switch to using url scheme wrappers instead of duplicating each command we wrap.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
328
diff
changeset
|
58 """ This function generates the local repository wrapper. """ |
75f082b5897e
Switch to using url scheme wrappers instead of duplicating each command we wrap.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
328
diff
changeset
|
59 |
347
537de0300510
Remove the 'outgoing' wrapper, and use the Mercurial infrastructure instead.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
345
diff
changeset
|
60 superclass = repo.__class__ |
537de0300510
Remove the 'outgoing' wrapper, and use the Mercurial infrastructure instead.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
345
diff
changeset
|
61 |
326
33736e2e25f0
alternate approach for supporting svn schemes for repository paths
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
158
diff
changeset
|
62 def remotesvn(fn): |
331
75f082b5897e
Switch to using url scheme wrappers instead of duplicating each command we wrap.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
328
diff
changeset
|
63 """ |
326
33736e2e25f0
alternate approach for supporting svn schemes for repository paths
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
158
diff
changeset
|
64 Filter for instance methods which require the first argument |
33736e2e25f0
alternate approach for supporting svn schemes for repository paths
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
158
diff
changeset
|
65 to be a remote Subversion repository instance. |
331
75f082b5897e
Switch to using url scheme wrappers instead of duplicating each command we wrap.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
328
diff
changeset
|
66 """ |
618
82bfc96a1311
svnrepo: support new discovery module introduced in 3d0591a66118
Augie Fackler <durin42@gmail.com>
parents:
617
diff
changeset
|
67 original = getattr(repo, fn.__name__, None) |
82bfc96a1311
svnrepo: support new discovery module introduced in 3d0591a66118
Augie Fackler <durin42@gmail.com>
parents:
617
diff
changeset
|
68 |
82bfc96a1311
svnrepo: support new discovery module introduced in 3d0591a66118
Augie Fackler <durin42@gmail.com>
parents:
617
diff
changeset
|
69 # remove when dropping support for hg < 1.6. |
82bfc96a1311
svnrepo: support new discovery module introduced in 3d0591a66118
Augie Fackler <durin42@gmail.com>
parents:
617
diff
changeset
|
70 if original is None and fn.__name__ == 'findoutgoing': |
82bfc96a1311
svnrepo: support new discovery module introduced in 3d0591a66118
Augie Fackler <durin42@gmail.com>
parents:
617
diff
changeset
|
71 return |
82bfc96a1311
svnrepo: support new discovery module introduced in 3d0591a66118
Augie Fackler <durin42@gmail.com>
parents:
617
diff
changeset
|
72 |
326
33736e2e25f0
alternate approach for supporting svn schemes for repository paths
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
158
diff
changeset
|
73 def wrapper(self, *args, **opts): |
342
76c833526fbc
Use fallbacks in the wrappers for Subversion support, instead of prefixes.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
337
diff
changeset
|
74 capable = getattr(args[0], 'capable', lambda x: False) |
76c833526fbc
Use fallbacks in the wrappers for Subversion support, instead of prefixes.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
337
diff
changeset
|
75 if capable('subversion'): |
326
33736e2e25f0
alternate approach for supporting svn schemes for repository paths
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
158
diff
changeset
|
76 return fn(self, *args, **opts) |
331
75f082b5897e
Switch to using url scheme wrappers instead of duplicating each command we wrap.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
328
diff
changeset
|
77 else: |
347
537de0300510
Remove the 'outgoing' wrapper, and use the Mercurial infrastructure instead.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
345
diff
changeset
|
78 return original(*args, **opts) |
326
33736e2e25f0
alternate approach for supporting svn schemes for repository paths
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
158
diff
changeset
|
79 wrapper.__name__ = fn.__name__ + '_wrapper' |
33736e2e25f0
alternate approach for supporting svn schemes for repository paths
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
158
diff
changeset
|
80 wrapper.__doc__ = fn.__doc__ |
33736e2e25f0
alternate approach for supporting svn schemes for repository paths
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
158
diff
changeset
|
81 return wrapper |
124
291925677a9f
tag_repo: remove gentags command, extend repo.tags(), HgChangeEditor now takes either repo or repo_path
Luke Opperman <luke@loppear.com>
parents:
diff
changeset
|
82 |
347
537de0300510
Remove the 'outgoing' wrapper, and use the Mercurial infrastructure instead.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
345
diff
changeset
|
83 class svnlocalrepo(superclass): |
831
be5bbb2f2d68
svnrepo: kludge to work around hash changes between stupid and replay in hg 1.9
Augie Fackler <durin42@gmail.com>
parents:
805
diff
changeset
|
84 def svn_commitctx(self, ctx): |
be5bbb2f2d68
svnrepo: kludge to work around hash changes between stupid and replay in hg 1.9
Augie Fackler <durin42@gmail.com>
parents:
805
diff
changeset
|
85 """Commits a ctx, but defeats manifest recycling introduced in hg 1.9.""" |
858
bb6a013abaed
phases: mark newly created commits from subversion as 'public' to fix #335
Sean Farley <sean@mcs.anl.gov>
parents:
844
diff
changeset
|
86 hash = self.commitctx(ctxctx(ctx)) |
877
2c9f4c1686fa
svnrepo: don't break on old hg versions that lack pushkey
Augie Fackler <raf@durin42.com>
parents:
858
diff
changeset
|
87 if phases is not None and getattr(self, 'pushkey', False): |
858
bb6a013abaed
phases: mark newly created commits from subversion as 'public' to fix #335
Sean Farley <sean@mcs.anl.gov>
parents:
844
diff
changeset
|
88 # set phase to be public |
bb6a013abaed
phases: mark newly created commits from subversion as 'public' to fix #335
Sean Farley <sean@mcs.anl.gov>
parents:
844
diff
changeset
|
89 self.pushkey('phases', self[hash].hex(), str(phases.draft), str(phases.public)) |
bb6a013abaed
phases: mark newly created commits from subversion as 'public' to fix #335
Sean Farley <sean@mcs.anl.gov>
parents:
844
diff
changeset
|
90 return hash |
831
be5bbb2f2d68
svnrepo: kludge to work around hash changes between stupid and replay in hg 1.9
Augie Fackler <durin42@gmail.com>
parents:
805
diff
changeset
|
91 |
617
da21c351d937
pull: handle argspec change from e43c23d189a5
Augie Fackler <durin42@gmail.com>
parents:
611
diff
changeset
|
92 # TODO use newbranch to allow branch creation in Subversion? |
331
75f082b5897e
Switch to using url scheme wrappers instead of duplicating each command we wrap.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
328
diff
changeset
|
93 @remotesvn |
617
da21c351d937
pull: handle argspec change from e43c23d189a5
Augie Fackler <durin42@gmail.com>
parents:
611
diff
changeset
|
94 def push(self, remote, force=False, revs=None, newbranch=None): |
347
537de0300510
Remove the 'outgoing' wrapper, and use the Mercurial infrastructure instead.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
345
diff
changeset
|
95 return wrappers.push(self, remote, force, revs) |
537de0300510
Remove the 'outgoing' wrapper, and use the Mercurial infrastructure instead.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
345
diff
changeset
|
96 |
537de0300510
Remove the 'outgoing' wrapper, and use the Mercurial infrastructure instead.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
345
diff
changeset
|
97 @remotesvn |
537de0300510
Remove the 'outgoing' wrapper, and use the Mercurial infrastructure instead.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
345
diff
changeset
|
98 def pull(self, remote, heads=[], force=False): |
537de0300510
Remove the 'outgoing' wrapper, and use the Mercurial infrastructure instead.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
345
diff
changeset
|
99 return wrappers.pull(self, remote, heads, force) |
537de0300510
Remove the 'outgoing' wrapper, and use the Mercurial infrastructure instead.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
345
diff
changeset
|
100 |
537de0300510
Remove the 'outgoing' wrapper, and use the Mercurial infrastructure instead.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
345
diff
changeset
|
101 @remotesvn |
537de0300510
Remove the 'outgoing' wrapper, and use the Mercurial infrastructure instead.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
345
diff
changeset
|
102 def findoutgoing(self, remote, base=None, heads=None, force=False): |
805
a3f727c41c1d
Fix breakage introduced by discovery refactoring
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents:
754
diff
changeset
|
103 return wrappers.findoutgoing(repo, remote, heads, force) |
331
75f082b5897e
Switch to using url scheme wrappers instead of duplicating each command we wrap.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
328
diff
changeset
|
104 |
748
e1e2af66953d
svnmeta: store subdir in a file, and verify it when loading.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
710
diff
changeset
|
105 def svnmeta(self, uuid=None, subdir=None): |
464
0f7095f53ca3
Extend svnrepos with SubversionRepo and SVNMeta
Patrick Mezard <pmezard@gmail.com>
parents:
443
diff
changeset
|
106 return svnmeta.SVNMeta(self, uuid, subdir) |
0f7095f53ca3
Extend svnrepos with SubversionRepo and SVNMeta
Patrick Mezard <pmezard@gmail.com>
parents:
443
diff
changeset
|
107 |
326
33736e2e25f0
alternate approach for supporting svn schemes for repository paths
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
158
diff
changeset
|
108 repo.__class__ = svnlocalrepo |
33736e2e25f0
alternate approach for supporting svn schemes for repository paths
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
158
diff
changeset
|
109 |
33736e2e25f0
alternate approach for supporting svn schemes for repository paths
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
158
diff
changeset
|
110 class svnremoterepo(mercurial.repo.repository): |
331
75f082b5897e
Switch to using url scheme wrappers instead of duplicating each command we wrap.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
328
diff
changeset
|
111 """ the dumb wrapper for actual Subversion repositories """ |
75f082b5897e
Switch to using url scheme wrappers instead of duplicating each command we wrap.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
328
diff
changeset
|
112 |
464
0f7095f53ca3
Extend svnrepos with SubversionRepo and SVNMeta
Patrick Mezard <pmezard@gmail.com>
parents:
443
diff
changeset
|
113 def __init__(self, ui, path=None): |
326
33736e2e25f0
alternate approach for supporting svn schemes for repository paths
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
158
diff
changeset
|
114 self.ui = ui |
464
0f7095f53ca3
Extend svnrepos with SubversionRepo and SVNMeta
Patrick Mezard <pmezard@gmail.com>
parents:
443
diff
changeset
|
115 if path is None: |
0f7095f53ca3
Extend svnrepos with SubversionRepo and SVNMeta
Patrick Mezard <pmezard@gmail.com>
parents:
443
diff
changeset
|
116 path = self.ui.config('paths', 'default') |
754
caa527346a0f
svncommands: abort on missing metadata or Subversion URL (fixes #226)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
750
diff
changeset
|
117 if not path: |
caa527346a0f
svncommands: abort on missing metadata or Subversion URL (fixes #226)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
750
diff
changeset
|
118 raise hgutil.Abort('no Subversion URL specified') |
326
33736e2e25f0
alternate approach for supporting svn schemes for repository paths
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
158
diff
changeset
|
119 self.path = path |
331
75f082b5897e
Switch to using url scheme wrappers instead of duplicating each command we wrap.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
328
diff
changeset
|
120 self.capabilities = set(['lookup', 'subversion']) |
844
95d040755254
Added ability to configure the password stores
Jerome M. BERGER <jerome.berger@sagemcom.com>
parents:
831
diff
changeset
|
121 pws = self.ui.config('hgsubversion', 'password_stores', None) |
95d040755254
Added ability to configure the password stores
Jerome M. BERGER <jerome.berger@sagemcom.com>
parents:
831
diff
changeset
|
122 if pws is not None: |
95d040755254
Added ability to configure the password stores
Jerome M. BERGER <jerome.berger@sagemcom.com>
parents:
831
diff
changeset
|
123 # Split pws at comas and strip neighbouring whitespace (whitespace |
95d040755254
Added ability to configure the password stores
Jerome M. BERGER <jerome.berger@sagemcom.com>
parents:
831
diff
changeset
|
124 # at the beginning and end of pws has already been removed by the |
95d040755254
Added ability to configure the password stores
Jerome M. BERGER <jerome.berger@sagemcom.com>
parents:
831
diff
changeset
|
125 # config parser). |
95d040755254
Added ability to configure the password stores
Jerome M. BERGER <jerome.berger@sagemcom.com>
parents:
831
diff
changeset
|
126 self.password_stores = re.split(r'\s*,\s*', pws) |
95d040755254
Added ability to configure the password stores
Jerome M. BERGER <jerome.berger@sagemcom.com>
parents:
831
diff
changeset
|
127 else: |
95d040755254
Added ability to configure the password stores
Jerome M. BERGER <jerome.berger@sagemcom.com>
parents:
831
diff
changeset
|
128 self.password_stores = None |
331
75f082b5897e
Switch to using url scheme wrappers instead of duplicating each command we wrap.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
328
diff
changeset
|
129 |
464
0f7095f53ca3
Extend svnrepos with SubversionRepo and SVNMeta
Patrick Mezard <pmezard@gmail.com>
parents:
443
diff
changeset
|
130 @propertycache |
468
037bba1c6736
svnrepo: expose the same svnurl than SubversionRepo
Patrick Mezard <pmezard@gmail.com>
parents:
464
diff
changeset
|
131 def svnauth(self): |
464
0f7095f53ca3
Extend svnrepos with SubversionRepo and SVNMeta
Patrick Mezard <pmezard@gmail.com>
parents:
443
diff
changeset
|
132 # DO NOT default the user to hg's getuser(). If you provide |
0f7095f53ca3
Extend svnrepos with SubversionRepo and SVNMeta
Patrick Mezard <pmezard@gmail.com>
parents:
443
diff
changeset
|
133 # *any* default username to Subversion, it won't use any remembered |
0f7095f53ca3
Extend svnrepos with SubversionRepo and SVNMeta
Patrick Mezard <pmezard@gmail.com>
parents:
443
diff
changeset
|
134 # username for the desired realm, breaking OS X Keychain support, |
0f7095f53ca3
Extend svnrepos with SubversionRepo and SVNMeta
Patrick Mezard <pmezard@gmail.com>
parents:
443
diff
changeset
|
135 # GNOME keyring support, and all similar tools. |
0f7095f53ca3
Extend svnrepos with SubversionRepo and SVNMeta
Patrick Mezard <pmezard@gmail.com>
parents:
443
diff
changeset
|
136 user = self.ui.config('hgsubversion', 'username') |
0f7095f53ca3
Extend svnrepos with SubversionRepo and SVNMeta
Patrick Mezard <pmezard@gmail.com>
parents:
443
diff
changeset
|
137 passwd = self.ui.config('hgsubversion', 'password') |
468
037bba1c6736
svnrepo: expose the same svnurl than SubversionRepo
Patrick Mezard <pmezard@gmail.com>
parents:
464
diff
changeset
|
138 url = util.normalize_url(self.path) |
037bba1c6736
svnrepo: expose the same svnurl than SubversionRepo
Patrick Mezard <pmezard@gmail.com>
parents:
464
diff
changeset
|
139 user, passwd, url = svnwrap.parse_url(url, user, passwd) |
037bba1c6736
svnrepo: expose the same svnurl than SubversionRepo
Patrick Mezard <pmezard@gmail.com>
parents:
464
diff
changeset
|
140 return url, user, passwd |
037bba1c6736
svnrepo: expose the same svnurl than SubversionRepo
Patrick Mezard <pmezard@gmail.com>
parents:
464
diff
changeset
|
141 |
037bba1c6736
svnrepo: expose the same svnurl than SubversionRepo
Patrick Mezard <pmezard@gmail.com>
parents:
464
diff
changeset
|
142 @property |
037bba1c6736
svnrepo: expose the same svnurl than SubversionRepo
Patrick Mezard <pmezard@gmail.com>
parents:
464
diff
changeset
|
143 def svnurl(self): |
710
db56e65906f4
svnrepo: make the svnurl property obtain the URL from Subversion.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
628
diff
changeset
|
144 return self.svn.svn_url |
468
037bba1c6736
svnrepo: expose the same svnurl than SubversionRepo
Patrick Mezard <pmezard@gmail.com>
parents:
464
diff
changeset
|
145 |
037bba1c6736
svnrepo: expose the same svnurl than SubversionRepo
Patrick Mezard <pmezard@gmail.com>
parents:
464
diff
changeset
|
146 @propertycache |
037bba1c6736
svnrepo: expose the same svnurl than SubversionRepo
Patrick Mezard <pmezard@gmail.com>
parents:
464
diff
changeset
|
147 def svn(self): |
611
b70f7c82b9b8
svncommands: fix layering violation & tweak error messages.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
597
diff
changeset
|
148 try: |
844
95d040755254
Added ability to configure the password stores
Jerome M. BERGER <jerome.berger@sagemcom.com>
parents:
831
diff
changeset
|
149 return svnwrap.SubversionRepo(*self.svnauth, password_stores=self.password_stores) |
611
b70f7c82b9b8
svncommands: fix layering violation & tweak error messages.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
597
diff
changeset
|
150 except svnwrap.SubversionConnectionException, e: |
b70f7c82b9b8
svncommands: fix layering violation & tweak error messages.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
597
diff
changeset
|
151 self.ui.traceback() |
b70f7c82b9b8
svncommands: fix layering violation & tweak error messages.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
597
diff
changeset
|
152 raise hgutil.Abort(e) |
464
0f7095f53ca3
Extend svnrepos with SubversionRepo and SVNMeta
Patrick Mezard <pmezard@gmail.com>
parents:
443
diff
changeset
|
153 |
326
33736e2e25f0
alternate approach for supporting svn schemes for repository paths
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
158
diff
changeset
|
154 def url(self): |
345
49a656155a92
remove pointless rstrip('/')
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
344
diff
changeset
|
155 return self.path |
326
33736e2e25f0
alternate approach for supporting svn schemes for repository paths
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
158
diff
changeset
|
156 |
33736e2e25f0
alternate approach for supporting svn schemes for repository paths
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
158
diff
changeset
|
157 def lookup(self, key): |
33736e2e25f0
alternate approach for supporting svn schemes for repository paths
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
158
diff
changeset
|
158 return key |
33736e2e25f0
alternate approach for supporting svn schemes for repository paths
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
158
diff
changeset
|
159 |
33736e2e25f0
alternate approach for supporting svn schemes for repository paths
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
158
diff
changeset
|
160 def cancopy(self): |
33736e2e25f0
alternate approach for supporting svn schemes for repository paths
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
158
diff
changeset
|
161 return False |
33736e2e25f0
alternate approach for supporting svn schemes for repository paths
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
158
diff
changeset
|
162 |
33736e2e25f0
alternate approach for supporting svn schemes for repository paths
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
158
diff
changeset
|
163 def heads(self, *args, **opts): |
33736e2e25f0
alternate approach for supporting svn schemes for repository paths
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
158
diff
changeset
|
164 """ |
33736e2e25f0
alternate approach for supporting svn schemes for repository paths
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
158
diff
changeset
|
165 Whenever this function is hit, we abort. The traceback is useful for |
33736e2e25f0
alternate approach for supporting svn schemes for repository paths
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
158
diff
changeset
|
166 figuring out where to intercept the functionality. |
33736e2e25f0
alternate approach for supporting svn schemes for repository paths
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
158
diff
changeset
|
167 """ |
33736e2e25f0
alternate approach for supporting svn schemes for repository paths
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
158
diff
changeset
|
168 raise hgutil.Abort('command unavailable for Subversion repositories') |
33736e2e25f0
alternate approach for supporting svn schemes for repository paths
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
158
diff
changeset
|
169 |
628
4375d37fea1e
svnrepo: fix issue 187: ignore pushable bookmarks in hg 1.6
James McKay <code@jamesmckay.net>
parents:
618
diff
changeset
|
170 def pushkey(self, namespace, key, old, new): |
4375d37fea1e
svnrepo: fix issue 187: ignore pushable bookmarks in hg 1.6
James McKay <code@jamesmckay.net>
parents:
618
diff
changeset
|
171 return False |
4375d37fea1e
svnrepo: fix issue 187: ignore pushable bookmarks in hg 1.6
James McKay <code@jamesmckay.net>
parents:
618
diff
changeset
|
172 |
4375d37fea1e
svnrepo: fix issue 187: ignore pushable bookmarks in hg 1.6
James McKay <code@jamesmckay.net>
parents:
618
diff
changeset
|
173 def listkeys(self, namespace): |
4375d37fea1e
svnrepo: fix issue 187: ignore pushable bookmarks in hg 1.6
James McKay <code@jamesmckay.net>
parents:
618
diff
changeset
|
174 return {} |
4375d37fea1e
svnrepo: fix issue 187: ignore pushable bookmarks in hg 1.6
James McKay <code@jamesmckay.net>
parents:
618
diff
changeset
|
175 |
326
33736e2e25f0
alternate approach for supporting svn schemes for repository paths
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
158
diff
changeset
|
176 def instance(ui, url, create): |
342
76c833526fbc
Use fallbacks in the wrappers for Subversion support, instead of prefixes.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
337
diff
changeset
|
177 if url.startswith('http://') or url.startswith('https://'): |
76c833526fbc
Use fallbacks in the wrappers for Subversion support, instead of prefixes.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
337
diff
changeset
|
178 try: |
76c833526fbc
Use fallbacks in the wrappers for Subversion support, instead of prefixes.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
337
diff
changeset
|
179 # may yield a bogus 'real URL...' message |
76c833526fbc
Use fallbacks in the wrappers for Subversion support, instead of prefixes.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
337
diff
changeset
|
180 return httprepo.instance(ui, url, create) |
76c833526fbc
Use fallbacks in the wrappers for Subversion support, instead of prefixes.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
337
diff
changeset
|
181 except error.RepoError: |
597
737292a31028
svnrepo: ease debugging of Subversion fallback
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
468
diff
changeset
|
182 ui.traceback() |
737292a31028
svnrepo: ease debugging of Subversion fallback
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
468
diff
changeset
|
183 ui.note('(falling back to Subversion support)\n') |
342
76c833526fbc
Use fallbacks in the wrappers for Subversion support, instead of prefixes.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
337
diff
changeset
|
184 |
326
33736e2e25f0
alternate approach for supporting svn schemes for repository paths
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
158
diff
changeset
|
185 if create: |
33736e2e25f0
alternate approach for supporting svn schemes for repository paths
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
158
diff
changeset
|
186 raise hgutil.Abort('cannot create new remote Subversion repository') |
33736e2e25f0
alternate approach for supporting svn schemes for repository paths
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
158
diff
changeset
|
187 |
331
75f082b5897e
Switch to using url scheme wrappers instead of duplicating each command we wrap.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
328
diff
changeset
|
188 return svnremoterepo(ui, url) |