Mercurial > hgsubversion
comparison svnexternals.py @ 331:75f082b5897e
Switch to using url scheme wrappers instead of duplicating each command we wrap.
The 'hg svn url' command has been killed; the replacement is
'.hg/hgrc'. More stuff related to its disappearance has been stripped,
including two tests.
HgChangeReceiver now takes a UUID argument, which it uses to ensure
that remote repositories remain unchanged. This is a temporary
solution, and I'm not entirely satisfied with how it's done either.
Access to the UUID file has been isolated in a HgChangeReceiver
property.
Some more tests have been updated to use ui.pushbuffer()/popbuffer(),
and to pass through the Mercurial API.
Moved the arguments to wrappers.pull() to the UI configuration.
Also, remove HgChangeReceiver.opts in favour of a 'usebranchnames'
instance & configuration variable. The name is taken from the
ConvertExtension.
author | Dan Villiom Podlaski Christiansen <danchr@gmail.com> |
---|---|
date | Fri, 15 May 2009 19:18:43 +0200 |
parents | 963d27a0b1c2 |
children |
comparison
equal
deleted
inserted
replaced
330:5f8f2fd4fd54 | 331:75f082b5897e |
---|---|
1 import cStringIO | 1 import cStringIO |
2 | 2 |
3 import os, re, shutil, stat, subprocess | 3 import os, re, shutil, stat, subprocess |
4 from mercurial import util as hgutil | 4 from mercurial import util as hgutil |
5 from mercurial.i18n import _ | 5 from mercurial.i18n import _ |
6 from hgsubversion import util | |
6 | 7 |
7 class externalsfile(dict): | 8 class externalsfile(dict): |
8 """Map svn directories to lists of externals entries. | 9 """Map svn directories to lists of externals entries. |
9 """ | 10 """ |
10 def __init__(self): | 11 def __init__(self): |
158 directory path. | 159 directory path. |
159 """ | 160 """ |
160 # Yes, this is ugly, but good enough for now | 161 # Yes, this is ugly, but good enough for now |
161 args = ['svn', 'info', '--xml', svnurl] | 162 args = ['svn', 'info', '--xml', svnurl] |
162 shell = os.name == 'nt' | 163 shell = os.name == 'nt' |
163 p = subprocess.Popen(args, stdout=subprocess.PIPE, shell=shell) | 164 p = subprocess.Popen(args, shell=shell, |
165 stdout=subprocess.PIPE, stderr=subprocess.STDOUT) | |
164 stdout = p.communicate()[0] | 166 stdout = p.communicate()[0] |
165 if p.returncode: | 167 if p.returncode: |
166 raise hgutil.Abort(_('cannot get information about %s') | 168 raise hgutil.Abort(_('cannot get information about %s') |
167 % svnurl) | 169 % svnurl) |
168 m = re.search(r'<root>(.*)</root>', stdout, re.S) | 170 m = re.search(r'<root>(.*)</root>', stdout, re.S) |
238 | 240 |
239 def svn(self, args, cwd): | 241 def svn(self, args, cwd): |
240 args = ['svn'] + args | 242 args = ['svn'] + args |
241 self.ui.debug(_('updating externals: %r, cwd=%s\n') % (args, cwd)) | 243 self.ui.debug(_('updating externals: %r, cwd=%s\n') % (args, cwd)) |
242 shell = os.name == 'nt' | 244 shell = os.name == 'nt' |
243 subprocess.check_call(args, cwd=cwd, shell=shell) | 245 subprocess.check_call(args, cwd=cwd, shell=shell, |
246 stdout=subprocess.PIPE, stderr=subprocess.STDOUT) | |
244 | 247 |
245 def updateexternals(ui, args, repo, **opts): | 248 def updateexternals(ui, args, repo, **opts): |
246 """update repository externals | 249 """update repository externals |
247 """ | 250 """ |
248 if len(args) > 1: | 251 if len(args) > 2: |
249 raise hgutil.Abort(_('updateexternals expects at most one changeset')) | 252 raise hgutil.Abort(_('updateexternals expects at most one changeset')) |
250 node = None | 253 node = None |
254 if len(args) == 2: | |
255 svnurl = util.normalize_url(repo.ui.expandpath(args[0])) | |
256 args = args[1:] | |
257 else: | |
258 svnurl = util.normalize_url(repo.ui.expandpath('default')) | |
251 if args: | 259 if args: |
252 node = args[0] | 260 node = args[0] |
253 | 261 |
254 try: | |
255 svnurl = file(repo.join('svn/url'), 'rb').read() | |
256 except: | |
257 raise hgutil.Abort(_('failed to retrieve original svn URL')) | |
258 svnroot = getsvninfo(svnurl)[1] | 262 svnroot = getsvninfo(svnurl)[1] |
259 | 263 |
260 # Retrieve current externals status | 264 # Retrieve current externals status |
261 try: | 265 try: |
262 oldext = file(repo.join('svn/externals'), 'rb').read() | 266 oldext = file(repo.join('svn/externals'), 'rb').read() |