annotate hgsubversion/svnrepo.py @ 844:95d040755254

Added ability to configure the password stores
author Jerome M. BERGER <jerome.berger@sagemcom.com>
date Tue, 22 Nov 2011 11:54:25 +0100
parents be5bbb2f2d68
children bb6a013abaed
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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
844
95d040755254 Added ability to configure the password stores
Jerome M. BERGER <jerome.berger@sagemcom.com>
parents: 831
diff changeset
24 import re
326
33736e2e25f0 alternate approach for supporting svn schemes for repository paths
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 158
diff changeset
25 import util
33736e2e25f0 alternate approach for supporting svn schemes for repository paths
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 158
diff changeset
26 import wrappers
464
0f7095f53ca3 Extend svnrepos with SubversionRepo and SVNMeta
Patrick Mezard <pmezard@gmail.com>
parents: 443
diff changeset
27 import svnwrap
0f7095f53ca3 Extend svnrepos with SubversionRepo and SVNMeta
Patrick Mezard <pmezard@gmail.com>
parents: 443
diff changeset
28 import svnmeta
0f7095f53ca3 Extend svnrepos with SubversionRepo and SVNMeta
Patrick Mezard <pmezard@gmail.com>
parents: 443
diff changeset
29
0f7095f53ca3 Extend svnrepos with SubversionRepo and SVNMeta
Patrick Mezard <pmezard@gmail.com>
parents: 443
diff changeset
30 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
31
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
32 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
33 """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
34 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
35 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
36
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
37 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
38 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
39
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 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
41 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
42 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
43 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
44
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 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
46 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
47
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 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
49 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
50
326
33736e2e25f0 alternate approach for supporting svn schemes for repository paths
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 158
diff changeset
51 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
52 """ 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
53
347
537de0300510 Remove the 'outgoing' wrapper, and use the Mercurial infrastructure instead.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 345
diff changeset
54 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
55
326
33736e2e25f0 alternate approach for supporting svn schemes for repository paths
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 158
diff changeset
56 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
57 """
326
33736e2e25f0 alternate approach for supporting svn schemes for repository paths
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 158
diff changeset
58 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
59 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
60 """
618
82bfc96a1311 svnrepo: support new discovery module introduced in 3d0591a66118
Augie Fackler <durin42@gmail.com>
parents: 617
diff changeset
61 original = getattr(repo, fn.__name__, None)
82bfc96a1311 svnrepo: support new discovery module introduced in 3d0591a66118
Augie Fackler <durin42@gmail.com>
parents: 617
diff changeset
62
82bfc96a1311 svnrepo: support new discovery module introduced in 3d0591a66118
Augie Fackler <durin42@gmail.com>
parents: 617
diff changeset
63 # 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
64 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
65 return
82bfc96a1311 svnrepo: support new discovery module introduced in 3d0591a66118
Augie Fackler <durin42@gmail.com>
parents: 617
diff changeset
66
326
33736e2e25f0 alternate approach for supporting svn schemes for repository paths
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 158
diff changeset
67 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
68 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
69 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
70 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
71 else:
347
537de0300510 Remove the 'outgoing' wrapper, and use the Mercurial infrastructure instead.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 345
diff changeset
72 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
73 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
74 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
75 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
76
347
537de0300510 Remove the 'outgoing' wrapper, and use the Mercurial infrastructure instead.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 345
diff changeset
77 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
78 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
79 """Commits a ctx, but defeats manifest recycling introduced in hg 1.9."""
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
80 return self.commitctx(ctxctx(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
81
617
da21c351d937 pull: handle argspec change from e43c23d189a5
Augie Fackler <durin42@gmail.com>
parents: 611
diff changeset
82 # 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
83 @remotesvn
617
da21c351d937 pull: handle argspec change from e43c23d189a5
Augie Fackler <durin42@gmail.com>
parents: 611
diff changeset
84 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
85 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
86
537de0300510 Remove the 'outgoing' wrapper, and use the Mercurial infrastructure instead.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 345
diff changeset
87 @remotesvn
537de0300510 Remove the 'outgoing' wrapper, and use the Mercurial infrastructure instead.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 345
diff changeset
88 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
89 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
90
537de0300510 Remove the 'outgoing' wrapper, and use the Mercurial infrastructure instead.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 345
diff changeset
91 @remotesvn
537de0300510 Remove the 'outgoing' wrapper, and use the Mercurial infrastructure instead.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 345
diff changeset
92 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
93 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
94
748
e1e2af66953d svnmeta: store subdir in a file, and verify it when loading.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 710
diff changeset
95 def svnmeta(self, uuid=None, subdir=None):
464
0f7095f53ca3 Extend svnrepos with SubversionRepo and SVNMeta
Patrick Mezard <pmezard@gmail.com>
parents: 443
diff changeset
96 return svnmeta.SVNMeta(self, uuid, subdir)
0f7095f53ca3 Extend svnrepos with SubversionRepo and SVNMeta
Patrick Mezard <pmezard@gmail.com>
parents: 443
diff changeset
97
326
33736e2e25f0 alternate approach for supporting svn schemes for repository paths
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 158
diff changeset
98 repo.__class__ = svnlocalrepo
33736e2e25f0 alternate approach for supporting svn schemes for repository paths
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 158
diff changeset
99
33736e2e25f0 alternate approach for supporting svn schemes for repository paths
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 158
diff changeset
100 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
101 """ 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
102
464
0f7095f53ca3 Extend svnrepos with SubversionRepo and SVNMeta
Patrick Mezard <pmezard@gmail.com>
parents: 443
diff changeset
103 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
104 self.ui = ui
464
0f7095f53ca3 Extend svnrepos with SubversionRepo and SVNMeta
Patrick Mezard <pmezard@gmail.com>
parents: 443
diff changeset
105 if path is None:
0f7095f53ca3 Extend svnrepos with SubversionRepo and SVNMeta
Patrick Mezard <pmezard@gmail.com>
parents: 443
diff changeset
106 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
107 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
108 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
109 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
110 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
111 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
112 if pws is not None:
95d040755254 Added ability to configure the password stores
Jerome M. BERGER <jerome.berger@sagemcom.com>
parents: 831
diff changeset
113 # 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
114 # 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
115 # config parser).
95d040755254 Added ability to configure the password stores
Jerome M. BERGER <jerome.berger@sagemcom.com>
parents: 831
diff changeset
116 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
117 else:
95d040755254 Added ability to configure the password stores
Jerome M. BERGER <jerome.berger@sagemcom.com>
parents: 831
diff changeset
118 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
119
464
0f7095f53ca3 Extend svnrepos with SubversionRepo and SVNMeta
Patrick Mezard <pmezard@gmail.com>
parents: 443
diff changeset
120 @propertycache
468
037bba1c6736 svnrepo: expose the same svnurl than SubversionRepo
Patrick Mezard <pmezard@gmail.com>
parents: 464
diff changeset
121 def svnauth(self):
464
0f7095f53ca3 Extend svnrepos with SubversionRepo and SVNMeta
Patrick Mezard <pmezard@gmail.com>
parents: 443
diff changeset
122 # 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
123 # *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
124 # 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
125 # GNOME keyring support, and all similar tools.
0f7095f53ca3 Extend svnrepos with SubversionRepo and SVNMeta
Patrick Mezard <pmezard@gmail.com>
parents: 443
diff changeset
126 user = self.ui.config('hgsubversion', 'username')
0f7095f53ca3 Extend svnrepos with SubversionRepo and SVNMeta
Patrick Mezard <pmezard@gmail.com>
parents: 443
diff changeset
127 passwd = self.ui.config('hgsubversion', 'password')
468
037bba1c6736 svnrepo: expose the same svnurl than SubversionRepo
Patrick Mezard <pmezard@gmail.com>
parents: 464
diff changeset
128 url = util.normalize_url(self.path)
037bba1c6736 svnrepo: expose the same svnurl than SubversionRepo
Patrick Mezard <pmezard@gmail.com>
parents: 464
diff changeset
129 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
130 return url, user, passwd
037bba1c6736 svnrepo: expose the same svnurl than SubversionRepo
Patrick Mezard <pmezard@gmail.com>
parents: 464
diff changeset
131
037bba1c6736 svnrepo: expose the same svnurl than SubversionRepo
Patrick Mezard <pmezard@gmail.com>
parents: 464
diff changeset
132 @property
037bba1c6736 svnrepo: expose the same svnurl than SubversionRepo
Patrick Mezard <pmezard@gmail.com>
parents: 464
diff changeset
133 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
134 return self.svn.svn_url
468
037bba1c6736 svnrepo: expose the same svnurl than SubversionRepo
Patrick Mezard <pmezard@gmail.com>
parents: 464
diff changeset
135
037bba1c6736 svnrepo: expose the same svnurl than SubversionRepo
Patrick Mezard <pmezard@gmail.com>
parents: 464
diff changeset
136 @propertycache
037bba1c6736 svnrepo: expose the same svnurl than SubversionRepo
Patrick Mezard <pmezard@gmail.com>
parents: 464
diff changeset
137 def svn(self):
611
b70f7c82b9b8 svncommands: fix layering violation & tweak error messages.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 597
diff changeset
138 try:
844
95d040755254 Added ability to configure the password stores
Jerome M. BERGER <jerome.berger@sagemcom.com>
parents: 831
diff changeset
139 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
140 except svnwrap.SubversionConnectionException, e:
b70f7c82b9b8 svncommands: fix layering violation & tweak error messages.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 597
diff changeset
141 self.ui.traceback()
b70f7c82b9b8 svncommands: fix layering violation & tweak error messages.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 597
diff changeset
142 raise hgutil.Abort(e)
464
0f7095f53ca3 Extend svnrepos with SubversionRepo and SVNMeta
Patrick Mezard <pmezard@gmail.com>
parents: 443
diff changeset
143
326
33736e2e25f0 alternate approach for supporting svn schemes for repository paths
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 158
diff changeset
144 def url(self):
345
49a656155a92 remove pointless rstrip('/')
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 344
diff changeset
145 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
146
33736e2e25f0 alternate approach for supporting svn schemes for repository paths
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 158
diff changeset
147 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
148 return key
33736e2e25f0 alternate approach for supporting svn schemes for repository paths
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 158
diff changeset
149
33736e2e25f0 alternate approach for supporting svn schemes for repository paths
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 158
diff changeset
150 def cancopy(self):
33736e2e25f0 alternate approach for supporting svn schemes for repository paths
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 158
diff changeset
151 return False
33736e2e25f0 alternate approach for supporting svn schemes for repository paths
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 158
diff changeset
152
33736e2e25f0 alternate approach for supporting svn schemes for repository paths
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 158
diff changeset
153 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
154 """
33736e2e25f0 alternate approach for supporting svn schemes for repository paths
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 158
diff changeset
155 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
156 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
157 """
33736e2e25f0 alternate approach for supporting svn schemes for repository paths
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 158
diff changeset
158 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
159
628
4375d37fea1e svnrepo: fix issue 187: ignore pushable bookmarks in hg 1.6
James McKay <code@jamesmckay.net>
parents: 618
diff changeset
160 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
161 return False
4375d37fea1e svnrepo: fix issue 187: ignore pushable bookmarks in hg 1.6
James McKay <code@jamesmckay.net>
parents: 618
diff changeset
162
4375d37fea1e svnrepo: fix issue 187: ignore pushable bookmarks in hg 1.6
James McKay <code@jamesmckay.net>
parents: 618
diff changeset
163 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
164 return {}
4375d37fea1e svnrepo: fix issue 187: ignore pushable bookmarks in hg 1.6
James McKay <code@jamesmckay.net>
parents: 618
diff changeset
165
326
33736e2e25f0 alternate approach for supporting svn schemes for repository paths
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 158
diff changeset
166 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
167 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
168 try:
76c833526fbc Use fallbacks in the wrappers for Subversion support, instead of prefixes.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 337
diff changeset
169 # 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
170 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
171 except error.RepoError:
597
737292a31028 svnrepo: ease debugging of Subversion fallback
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 468
diff changeset
172 ui.traceback()
737292a31028 svnrepo: ease debugging of Subversion fallback
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 468
diff changeset
173 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
174
326
33736e2e25f0 alternate approach for supporting svn schemes for repository paths
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 158
diff changeset
175 if create:
33736e2e25f0 alternate approach for supporting svn schemes for repository paths
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 158
diff changeset
176 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
177
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
178 return svnremoterepo(ui, url)