annotate hgsubversion/util.py @ 1009:f0bde4bf1f78

revsets: add support for 'r123' revision labels This is controlled by an hgsubversion.nativerevs boolean (off by default).
author Matt Mackall <mpm@selenic.com>
date Tue, 23 Apr 2013 13:59:38 -0500
parents 9ffa1daf7b08
children f0ebc7113429
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
889
7a98fbadcae9 revsets: huge speedups for fromsvn and svnrev
Bryan O'Sullivan <bryano@fb.com>
parents: 884
diff changeset
1 import errno
440
80909328aef1 move remaining cmdutils into util
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 431
diff changeset
2 import re
0
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
3 import os
440
80909328aef1 move remaining cmdutils into util
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 431
diff changeset
4 import urllib
951
bd9c292665fd editor: add a small changectx cache
Patrick Mezard <patrick@mezard.eu>
parents: 944
diff changeset
5 from collections import deque
0
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
6
620
8acae2416ec1 wrappers: cope with remoteui move to hg (hg cset d1908cb95a82)
Augie Fackler <durin42@gmail.com>
parents: 619
diff changeset
7 from mercurial import cmdutil
722
aa24148a7454 uisetup: add fromsvn() and svnrev() revsets.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 707
diff changeset
8 from mercurial import error
196
77812f98e250 Add a naive hg svn version command that works as long as hgsubversion is run from a checkout.
Augie Fackler <durin42@gmail.com>
parents: 195
diff changeset
9 from mercurial import hg
34
50d55c3e0d85 Some refactors of the previous change, including transparent upgrade of old-style pickled dictionaries.
Augie Fackler <durin42@gmail.com>
parents: 19
diff changeset
10 from mercurial import node
250
79349fd04836 utils: standardizing imported name to hgutil, our_util to util
Daniel Tang <dytang@cs.purdue.edu>
parents: 249
diff changeset
11 from mercurial import util as hgutil
34
50d55c3e0d85 Some refactors of the previous change, including transparent upgrade of old-style pickled dictionaries.
Augie Fackler <durin42@gmail.com>
parents: 19
diff changeset
12
722
aa24148a7454 uisetup: add fromsvn() and svnrev() revsets.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 707
diff changeset
13 try:
aa24148a7454 uisetup: add fromsvn() and svnrev() revsets.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 707
diff changeset
14 from mercurial import revset
aa24148a7454 uisetup: add fromsvn() and svnrev() revsets.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 707
diff changeset
15 except ImportError:
aa24148a7454 uisetup: add fromsvn() and svnrev() revsets.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 707
diff changeset
16 pass
196
77812f98e250 Add a naive hg svn version command that works as long as hgsubversion is run from a checkout.
Augie Fackler <durin42@gmail.com>
parents: 195
diff changeset
17
889
7a98fbadcae9 revsets: huge speedups for fromsvn and svnrev
Bryan O'Sullivan <bryano@fb.com>
parents: 884
diff changeset
18 import maps
7a98fbadcae9 revsets: huge speedups for fromsvn and svnrev
Bryan O'Sullivan <bryano@fb.com>
parents: 884
diff changeset
19
764
bc5c176b63eb svnexternals: support pushing subrepo based externals
Patrick Mezard <pmezard@gmail.com>
parents: 760
diff changeset
20 ignoredfiles = set(['.hgtags', '.hgsvnexternals', '.hgsub', '.hgsubstate'])
760
bf1c27a89c76 Extract files not to be pushed in util
Patrick Mezard <pmezard@gmail.com>
parents: 754
diff changeset
21
440
80909328aef1 move remaining cmdutils into util
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 431
diff changeset
22 b_re = re.compile(r'^\+\+\+ b\/([^\n]*)', re.MULTILINE)
80909328aef1 move remaining cmdutils into util
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 431
diff changeset
23 a_re = re.compile(r'^--- a\/([^\n]*)', re.MULTILINE)
80909328aef1 move remaining cmdutils into util
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 431
diff changeset
24 devnull_re = re.compile(r'^([-+]{3}) /dev/null', re.MULTILINE)
80909328aef1 move remaining cmdutils into util
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 431
diff changeset
25 header_re = re.compile(r'^diff --git .* b\/(.*)', re.MULTILINE)
80909328aef1 move remaining cmdutils into util
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 431
diff changeset
26 newfile_devnull_re = re.compile(r'^--- /dev/null\n\+\+\+ b/([^\n]*)',
80909328aef1 move remaining cmdutils into util
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 431
diff changeset
27 re.MULTILINE)
80909328aef1 move remaining cmdutils into util
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 431
diff changeset
28
80909328aef1 move remaining cmdutils into util
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 431
diff changeset
29
80909328aef1 move remaining cmdutils into util
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 431
diff changeset
30 def formatrev(rev):
80909328aef1 move remaining cmdutils into util
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 431
diff changeset
31 if rev == -1:
80909328aef1 move remaining cmdutils into util
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 431
diff changeset
32 return '\t(working copy)'
80909328aef1 move remaining cmdutils into util
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 431
diff changeset
33 return '\t(revision %d)' % rev
80909328aef1 move remaining cmdutils into util
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 431
diff changeset
34
973
21197f5ee9de expand configured paths
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 952
diff changeset
35 def configpath(ui, name):
21197f5ee9de expand configured paths
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 952
diff changeset
36 path = ui.config('hgsubversion', name)
21197f5ee9de expand configured paths
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 952
diff changeset
37 return path and hgutil.expandpath(path)
440
80909328aef1 move remaining cmdutils into util
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 431
diff changeset
38
80909328aef1 move remaining cmdutils into util
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 431
diff changeset
39 def filterdiff(diff, oldrev, newrev):
80909328aef1 move remaining cmdutils into util
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 431
diff changeset
40 diff = newfile_devnull_re.sub(r'--- \1\t(revision 0)' '\n'
80909328aef1 move remaining cmdutils into util
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 431
diff changeset
41 r'+++ \1\t(working copy)',
80909328aef1 move remaining cmdutils into util
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 431
diff changeset
42 diff)
80909328aef1 move remaining cmdutils into util
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 431
diff changeset
43 oldrev = formatrev(oldrev)
80909328aef1 move remaining cmdutils into util
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 431
diff changeset
44 newrev = formatrev(newrev)
832
e9af7eba88db globally: clean up whitespace around operators and commas to conform with PEP8
Yonggang Luo <luoyonggang@gmail.com>
parents: 828
diff changeset
45 diff = a_re.sub(r'--- \1' + oldrev, diff)
440
80909328aef1 move remaining cmdutils into util
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 431
diff changeset
46 diff = b_re.sub(r'+++ \1' + newrev, diff)
80909328aef1 move remaining cmdutils into util
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 431
diff changeset
47 diff = devnull_re.sub(r'\1 /dev/null\t(working copy)', diff)
80909328aef1 move remaining cmdutils into util
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 431
diff changeset
48 diff = header_re.sub(r'Index: \1' + '\n' + ('=' * 67), diff)
80909328aef1 move remaining cmdutils into util
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 431
diff changeset
49 return diff
80909328aef1 move remaining cmdutils into util
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 431
diff changeset
50
80909328aef1 move remaining cmdutils into util
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 431
diff changeset
51
80909328aef1 move remaining cmdutils into util
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 431
diff changeset
52 def parentrev(ui, repo, meta, hashes):
80909328aef1 move remaining cmdutils into util
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 431
diff changeset
53 """Find the svn parent revision of the repo's dirstate.
80909328aef1 move remaining cmdutils into util
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 431
diff changeset
54 """
80909328aef1 move remaining cmdutils into util
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 431
diff changeset
55 workingctx = repo.parents()[0]
80909328aef1 move remaining cmdutils into util
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 431
diff changeset
56 outrev = outgoing_revisions(repo, hashes, workingctx.node())
80909328aef1 move remaining cmdutils into util
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 431
diff changeset
57 if outrev:
80909328aef1 move remaining cmdutils into util
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 431
diff changeset
58 workingctx = repo[outrev[-1]].parents()[0]
80909328aef1 move remaining cmdutils into util
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 431
diff changeset
59 return workingctx
80909328aef1 move remaining cmdutils into util
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 431
diff changeset
60
80909328aef1 move remaining cmdutils into util
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 431
diff changeset
61
80909328aef1 move remaining cmdutils into util
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 431
diff changeset
62 def islocalrepo(url):
806
ec074ebaa80f util: make islocalrepo() a bit more tolerant with file:// urls
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents: 805
diff changeset
63 path = str(url) # convert once up front
ec074ebaa80f util: make islocalrepo() a bit more tolerant with file:// urls
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents: 805
diff changeset
64 if path.startswith('file:///'):
ec074ebaa80f util: make islocalrepo() a bit more tolerant with file:// urls
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents: 805
diff changeset
65 prefixlen = len('file://')
ec074ebaa80f util: make islocalrepo() a bit more tolerant with file:// urls
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents: 805
diff changeset
66 elif path.startswith('file:/'):
ec074ebaa80f util: make islocalrepo() a bit more tolerant with file:// urls
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents: 805
diff changeset
67 prefixlen = len('file:')
ec074ebaa80f util: make islocalrepo() a bit more tolerant with file:// urls
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents: 805
diff changeset
68 else:
440
80909328aef1 move remaining cmdutils into util
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 431
diff changeset
69 return False
806
ec074ebaa80f util: make islocalrepo() a bit more tolerant with file:// urls
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents: 805
diff changeset
70 if '#' in path.split('/')[-1]: # strip off #anchor
ec074ebaa80f util: make islocalrepo() a bit more tolerant with file:// urls
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents: 805
diff changeset
71 path = path[:path.rfind('#')]
ec074ebaa80f util: make islocalrepo() a bit more tolerant with file:// urls
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents: 805
diff changeset
72 path = url[prefixlen:]
440
80909328aef1 move remaining cmdutils into util
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 431
diff changeset
73 path = urllib.url2pathname(path).replace(os.sep, '/')
80909328aef1 move remaining cmdutils into util
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 431
diff changeset
74 while '/' in path:
832
e9af7eba88db globally: clean up whitespace around operators and commas to conform with PEP8
Yonggang Luo <luoyonggang@gmail.com>
parents: 828
diff changeset
75 if reduce(lambda x, y: x and y,
440
80909328aef1 move remaining cmdutils into util
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 431
diff changeset
76 map(lambda p: os.path.exists(os.path.join(path, p)),
832
e9af7eba88db globally: clean up whitespace around operators and commas to conform with PEP8
Yonggang Luo <luoyonggang@gmail.com>
parents: 828
diff changeset
77 ('hooks', 'format', 'db',))):
440
80909328aef1 move remaining cmdutils into util
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 431
diff changeset
78 return True
80909328aef1 move remaining cmdutils into util
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 431
diff changeset
79 path = path.rsplit('/', 1)[0]
80909328aef1 move remaining cmdutils into util
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 431
diff changeset
80 return False
80909328aef1 move remaining cmdutils into util
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 431
diff changeset
81
80909328aef1 move remaining cmdutils into util
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 431
diff changeset
82
196
77812f98e250 Add a naive hg svn version command that works as long as hgsubversion is run from a checkout.
Augie Fackler <durin42@gmail.com>
parents: 195
diff changeset
83 def version(ui):
509
ac9c9e1a8022 setup: write out version info
Augie Fackler <durin42@gmail.com>
parents: 497
diff changeset
84 """Return version information if available."""
ac9c9e1a8022 setup: write out version info
Augie Fackler <durin42@gmail.com>
parents: 497
diff changeset
85 try:
ac9c9e1a8022 setup: write out version info
Augie Fackler <durin42@gmail.com>
parents: 497
diff changeset
86 import __version__
ac9c9e1a8022 setup: write out version info
Augie Fackler <durin42@gmail.com>
parents: 497
diff changeset
87 return __version__.version
ac9c9e1a8022 setup: write out version info
Augie Fackler <durin42@gmail.com>
parents: 497
diff changeset
88 except ImportError:
ac9c9e1a8022 setup: write out version info
Augie Fackler <durin42@gmail.com>
parents: 497
diff changeset
89 try:
ac9c9e1a8022 setup: write out version info
Augie Fackler <durin42@gmail.com>
parents: 497
diff changeset
90 dn = os.path.dirname
ac9c9e1a8022 setup: write out version info
Augie Fackler <durin42@gmail.com>
parents: 497
diff changeset
91 repo = hg.repository(ui, dn(dn(__file__)))
ac9c9e1a8022 setup: write out version info
Augie Fackler <durin42@gmail.com>
parents: 497
diff changeset
92 ver = repo.dirstate.parents()[0]
ac9c9e1a8022 setup: write out version info
Augie Fackler <durin42@gmail.com>
parents: 497
diff changeset
93 return node.hex(ver)[:12]
ac9c9e1a8022 setup: write out version info
Augie Fackler <durin42@gmail.com>
parents: 497
diff changeset
94 except:
ac9c9e1a8022 setup: write out version info
Augie Fackler <durin42@gmail.com>
parents: 497
diff changeset
95 return 'unknown'
196
77812f98e250 Add a naive hg svn version command that works as long as hgsubversion is run from a checkout.
Augie Fackler <durin42@gmail.com>
parents: 195
diff changeset
96
0
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
97
469
5567af673f83 Revive svn+http(s) URLs support (issue94)
Patrick Mezard <pmezard@gmail.com>
parents: 465
diff changeset
98 def normalize_url(url):
754
caa527346a0f svncommands: abort on missing metadata or Subversion URL (fixes #226)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 752
diff changeset
99 if not url:
caa527346a0f svncommands: abort on missing metadata or Subversion URL (fixes #226)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 752
diff changeset
100 return url
475
15443c592f7a Remove the svn+ from svn+https urls before calling the Subversion API. This was already being done for svn+http urls.
David Stanek <dstanek@dstanek.com>
parents: 469
diff changeset
101 if url.startswith('svn+http://') or url.startswith('svn+https://'):
469
5567af673f83 Revive svn+http(s) URLs support (issue94)
Patrick Mezard <pmezard@gmail.com>
parents: 465
diff changeset
102 url = url[4:]
555
cbd7065e6ab4 util: add parseurl method to abstract away differences between 1.4 and 1.5
Augie Fackler <durin42@gmail.com>
parents: 509
diff changeset
103 url, revs, checkout = parseurl(url)
284
f8f9a2993705 Implement parseurl support (#revision in repository urls)
Martijn Pieters <mj@zopatista.com>
parents: 281
diff changeset
104 url = url.rstrip('/')
f8f9a2993705 Implement parseurl support (#revision in repository urls)
Martijn Pieters <mj@zopatista.com>
parents: 281
diff changeset
105 if checkout:
f8f9a2993705 Implement parseurl support (#revision in repository urls)
Martijn Pieters <mj@zopatista.com>
parents: 281
diff changeset
106 url = '%s#%s' % (url, checkout)
f8f9a2993705 Implement parseurl support (#revision in repository urls)
Martijn Pieters <mj@zopatista.com>
parents: 281
diff changeset
107 return url
140
9ffde8662967 util: Add a command to normalize svn urls and use it in a couple of places. Test that it works and prevents failed assertions.
Augie Fackler <durin42@gmail.com>
parents: 124
diff changeset
108
828
016f11e5f189 utils: add {save,load}_string since this is a fairly common idiom
Yonggang Luo <luoyonggang@gmail.com>
parents: 806
diff changeset
109
016f11e5f189 utils: add {save,load}_string since this is a fairly common idiom
Yonggang Luo <luoyonggang@gmail.com>
parents: 806
diff changeset
110 def load_string(file_path, default=None, limit=1024):
016f11e5f189 utils: add {save,load}_string since this is a fairly common idiom
Yonggang Luo <luoyonggang@gmail.com>
parents: 806
diff changeset
111 if not os.path.exists(file_path):
016f11e5f189 utils: add {save,load}_string since this is a fairly common idiom
Yonggang Luo <luoyonggang@gmail.com>
parents: 806
diff changeset
112 return default
016f11e5f189 utils: add {save,load}_string since this is a fairly common idiom
Yonggang Luo <luoyonggang@gmail.com>
parents: 806
diff changeset
113 try:
016f11e5f189 utils: add {save,load}_string since this is a fairly common idiom
Yonggang Luo <luoyonggang@gmail.com>
parents: 806
diff changeset
114 f = open(file_path, 'r')
016f11e5f189 utils: add {save,load}_string since this is a fairly common idiom
Yonggang Luo <luoyonggang@gmail.com>
parents: 806
diff changeset
115 ret = f.read(limit)
016f11e5f189 utils: add {save,load}_string since this is a fairly common idiom
Yonggang Luo <luoyonggang@gmail.com>
parents: 806
diff changeset
116 f.close()
016f11e5f189 utils: add {save,load}_string since this is a fairly common idiom
Yonggang Luo <luoyonggang@gmail.com>
parents: 806
diff changeset
117 except:
016f11e5f189 utils: add {save,load}_string since this is a fairly common idiom
Yonggang Luo <luoyonggang@gmail.com>
parents: 806
diff changeset
118 return default
016f11e5f189 utils: add {save,load}_string since this is a fairly common idiom
Yonggang Luo <luoyonggang@gmail.com>
parents: 806
diff changeset
119 if ret == '':
016f11e5f189 utils: add {save,load}_string since this is a fairly common idiom
Yonggang Luo <luoyonggang@gmail.com>
parents: 806
diff changeset
120 return default
016f11e5f189 utils: add {save,load}_string since this is a fairly common idiom
Yonggang Luo <luoyonggang@gmail.com>
parents: 806
diff changeset
121 return ret
016f11e5f189 utils: add {save,load}_string since this is a fairly common idiom
Yonggang Luo <luoyonggang@gmail.com>
parents: 806
diff changeset
122
016f11e5f189 utils: add {save,load}_string since this is a fairly common idiom
Yonggang Luo <luoyonggang@gmail.com>
parents: 806
diff changeset
123
016f11e5f189 utils: add {save,load}_string since this is a fairly common idiom
Yonggang Luo <luoyonggang@gmail.com>
parents: 806
diff changeset
124 def save_string(file_path, string):
016f11e5f189 utils: add {save,load}_string since this is a fairly common idiom
Yonggang Luo <luoyonggang@gmail.com>
parents: 806
diff changeset
125 if string is None:
016f11e5f189 utils: add {save,load}_string since this is a fairly common idiom
Yonggang Luo <luoyonggang@gmail.com>
parents: 806
diff changeset
126 string = ""
016f11e5f189 utils: add {save,load}_string since this is a fairly common idiom
Yonggang Luo <luoyonggang@gmail.com>
parents: 806
diff changeset
127 f = open(file_path, 'wb')
016f11e5f189 utils: add {save,load}_string since this is a fairly common idiom
Yonggang Luo <luoyonggang@gmail.com>
parents: 806
diff changeset
128 f.write(str(string))
016f11e5f189 utils: add {save,load}_string since this is a fairly common idiom
Yonggang Luo <luoyonggang@gmail.com>
parents: 806
diff changeset
129 f.close()
016f11e5f189 utils: add {save,load}_string since this is a fairly common idiom
Yonggang Luo <luoyonggang@gmail.com>
parents: 806
diff changeset
130
016f11e5f189 utils: add {save,load}_string since this is a fairly common idiom
Yonggang Luo <luoyonggang@gmail.com>
parents: 806
diff changeset
131
580
35529f736fa2 util: add progress wrapper to maintain 1.3 support
Augie Fackler <durin42@gmail.com>
parents: 555
diff changeset
132 # TODO remove when we drop 1.3 support
35529f736fa2 util: add progress wrapper to maintain 1.3 support
Augie Fackler <durin42@gmail.com>
parents: 555
diff changeset
133 def progress(ui, *args, **kwargs):
35529f736fa2 util: add progress wrapper to maintain 1.3 support
Augie Fackler <durin42@gmail.com>
parents: 555
diff changeset
134 if getattr(ui, 'progress', False):
35529f736fa2 util: add progress wrapper to maintain 1.3 support
Augie Fackler <durin42@gmail.com>
parents: 555
diff changeset
135 return ui.progress(*args, **kwargs)
140
9ffde8662967 util: Add a command to normalize svn urls and use it in a couple of places. Test that it works and prevents failed assertions.
Augie Fackler <durin42@gmail.com>
parents: 124
diff changeset
136
620
8acae2416ec1 wrappers: cope with remoteui move to hg (hg cset d1908cb95a82)
Augie Fackler <durin42@gmail.com>
parents: 619
diff changeset
137 # TODO remove when we drop 1.5 support
8acae2416ec1 wrappers: cope with remoteui move to hg (hg cset d1908cb95a82)
Augie Fackler <durin42@gmail.com>
parents: 619
diff changeset
138 remoteui = getattr(cmdutil, 'remoteui', getattr(hg, 'remoteui', False))
8acae2416ec1 wrappers: cope with remoteui move to hg (hg cset d1908cb95a82)
Augie Fackler <durin42@gmail.com>
parents: 619
diff changeset
139 if not remoteui:
8acae2416ec1 wrappers: cope with remoteui move to hg (hg cset d1908cb95a82)
Augie Fackler <durin42@gmail.com>
parents: 619
diff changeset
140 raise ImportError('Failed to import remoteui')
8acae2416ec1 wrappers: cope with remoteui move to hg (hg cset d1908cb95a82)
Augie Fackler <durin42@gmail.com>
parents: 619
diff changeset
141
555
cbd7065e6ab4 util: add parseurl method to abstract away differences between 1.4 and 1.5
Augie Fackler <durin42@gmail.com>
parents: 509
diff changeset
142 def parseurl(url, heads=[]):
cbd7065e6ab4 util: add parseurl method to abstract away differences between 1.4 and 1.5
Augie Fackler <durin42@gmail.com>
parents: 509
diff changeset
143 parsed = hg.parseurl(url, heads)
cbd7065e6ab4 util: add parseurl method to abstract away differences between 1.4 and 1.5
Augie Fackler <durin42@gmail.com>
parents: 509
diff changeset
144 if len(parsed) == 3:
cbd7065e6ab4 util: add parseurl method to abstract away differences between 1.4 and 1.5
Augie Fackler <durin42@gmail.com>
parents: 509
diff changeset
145 # old hg, remove when we can be 1.5-only
cbd7065e6ab4 util: add parseurl method to abstract away differences between 1.4 and 1.5
Augie Fackler <durin42@gmail.com>
parents: 509
diff changeset
146 svn_url, heads, checkout = parsed
cbd7065e6ab4 util: add parseurl method to abstract away differences between 1.4 and 1.5
Augie Fackler <durin42@gmail.com>
parents: 509
diff changeset
147 else:
cbd7065e6ab4 util: add parseurl method to abstract away differences between 1.4 and 1.5
Augie Fackler <durin42@gmail.com>
parents: 509
diff changeset
148 svn_url, heads = parsed
619
8beb5e28c23b util: handle change to hg.parseurl from 3d6915f5a2bb
Augie Fackler <durin42@gmail.com>
parents: 582
diff changeset
149 if isinstance(heads, tuple) and len(heads) == 2:
8beb5e28c23b util: handle change to hg.parseurl from 3d6915f5a2bb
Augie Fackler <durin42@gmail.com>
parents: 582
diff changeset
150 # hg 1.6 or later
8beb5e28c23b util: handle change to hg.parseurl from 3d6915f5a2bb
Augie Fackler <durin42@gmail.com>
parents: 582
diff changeset
151 _junk, heads = heads
555
cbd7065e6ab4 util: add parseurl method to abstract away differences between 1.4 and 1.5
Augie Fackler <durin42@gmail.com>
parents: 509
diff changeset
152 if heads:
cbd7065e6ab4 util: add parseurl method to abstract away differences between 1.4 and 1.5
Augie Fackler <durin42@gmail.com>
parents: 509
diff changeset
153 checkout = heads[0]
cbd7065e6ab4 util: add parseurl method to abstract away differences between 1.4 and 1.5
Augie Fackler <durin42@gmail.com>
parents: 509
diff changeset
154 else:
cbd7065e6ab4 util: add parseurl method to abstract away differences between 1.4 and 1.5
Augie Fackler <durin42@gmail.com>
parents: 509
diff changeset
155 checkout = None
cbd7065e6ab4 util: add parseurl method to abstract away differences between 1.4 and 1.5
Augie Fackler <durin42@gmail.com>
parents: 509
diff changeset
156 return svn_url, heads, checkout
cbd7065e6ab4 util: add parseurl method to abstract away differences between 1.4 and 1.5
Augie Fackler <durin42@gmail.com>
parents: 509
diff changeset
157
cbd7065e6ab4 util: add parseurl method to abstract away differences between 1.4 and 1.5
Augie Fackler <durin42@gmail.com>
parents: 509
diff changeset
158
39
b3c7b844b782 Some more fixes of cases discovered in the melange repo. If anyone knows how I can reproduce a "replaced" state in Subversion, I'd love to be able to make a real test case for this code.
Augie Fackler <durin42@gmail.com>
parents: 34
diff changeset
159 class PrefixMatch(object):
b3c7b844b782 Some more fixes of cases discovered in the melange repo. If anyone knows how I can reproduce a "replaced" state in Subversion, I'd love to be able to make a real test case for this code.
Augie Fackler <durin42@gmail.com>
parents: 34
diff changeset
160 def __init__(self, prefix):
b3c7b844b782 Some more fixes of cases discovered in the melange repo. If anyone knows how I can reproduce a "replaced" state in Subversion, I'd love to be able to make a real test case for this code.
Augie Fackler <durin42@gmail.com>
parents: 34
diff changeset
161 self.p = prefix
140
9ffde8662967 util: Add a command to normalize svn urls and use it in a couple of places. Test that it works and prevents failed assertions.
Augie Fackler <durin42@gmail.com>
parents: 124
diff changeset
162
39
b3c7b844b782 Some more fixes of cases discovered in the melange repo. If anyone knows how I can reproduce a "replaced" state in Subversion, I'd love to be able to make a real test case for this code.
Augie Fackler <durin42@gmail.com>
parents: 34
diff changeset
163 def files(self):
b3c7b844b782 Some more fixes of cases discovered in the melange repo. If anyone knows how I can reproduce a "replaced" state in Subversion, I'd love to be able to make a real test case for this code.
Augie Fackler <durin42@gmail.com>
parents: 34
diff changeset
164 return []
140
9ffde8662967 util: Add a command to normalize svn urls and use it in a couple of places. Test that it works and prevents failed assertions.
Augie Fackler <durin42@gmail.com>
parents: 124
diff changeset
165
39
b3c7b844b782 Some more fixes of cases discovered in the melange repo. If anyone knows how I can reproduce a "replaced" state in Subversion, I'd love to be able to make a real test case for this code.
Augie Fackler <durin42@gmail.com>
parents: 34
diff changeset
166 def __call__(self, fn):
b3c7b844b782 Some more fixes of cases discovered in the melange repo. If anyone knows how I can reproduce a "replaced" state in Subversion, I'd love to be able to make a real test case for this code.
Augie Fackler <durin42@gmail.com>
parents: 34
diff changeset
167 return fn.startswith(self.p)
99
1da7aafdd323 Refactored outgoing_revisions into util where it really belongs.
Augie Fackler <durin42@gmail.com>
parents: 39
diff changeset
168
416
cd6317fe70be invert the svnmeta/editor relationship
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 410
diff changeset
169 def outgoing_revisions(repo, reverse_map, sourcerev):
99
1da7aafdd323 Refactored outgoing_revisions into util where it really belongs.
Augie Fackler <durin42@gmail.com>
parents: 39
diff changeset
170 """Given a repo and an hg_editor, determines outgoing revisions for the
1da7aafdd323 Refactored outgoing_revisions into util where it really belongs.
Augie Fackler <durin42@gmail.com>
parents: 39
diff changeset
171 current working copy state.
1da7aafdd323 Refactored outgoing_revisions into util where it really belongs.
Augie Fackler <durin42@gmail.com>
parents: 39
diff changeset
172 """
1da7aafdd323 Refactored outgoing_revisions into util where it really belongs.
Augie Fackler <durin42@gmail.com>
parents: 39
diff changeset
173 outgoing_rev_hashes = []
152
1fde85a10f9e push: Fix the bad implementation that required modifying the dirstate to push.
Augie Fackler <durin42@gmail.com>
parents: 140
diff changeset
174 if sourcerev in reverse_map:
99
1da7aafdd323 Refactored outgoing_revisions into util where it really belongs.
Augie Fackler <durin42@gmail.com>
parents: 39
diff changeset
175 return
152
1fde85a10f9e push: Fix the bad implementation that required modifying the dirstate to push.
Augie Fackler <durin42@gmail.com>
parents: 140
diff changeset
176 sourcerev = repo[sourcerev]
1fde85a10f9e push: Fix the bad implementation that required modifying the dirstate to push.
Augie Fackler <durin42@gmail.com>
parents: 140
diff changeset
177 while (not sourcerev.node() in reverse_map
1fde85a10f9e push: Fix the bad implementation that required modifying the dirstate to push.
Augie Fackler <durin42@gmail.com>
parents: 140
diff changeset
178 and sourcerev.node() != node.nullid):
1fde85a10f9e push: Fix the bad implementation that required modifying the dirstate to push.
Augie Fackler <durin42@gmail.com>
parents: 140
diff changeset
179 outgoing_rev_hashes.append(sourcerev.node())
1fde85a10f9e push: Fix the bad implementation that required modifying the dirstate to push.
Augie Fackler <durin42@gmail.com>
parents: 140
diff changeset
180 sourcerev = sourcerev.parents()
221
ced45b753ba7 util: better error messages when finding svn parent of a revision.
Augie Fackler <durin42@gmail.com>
parents: 198
diff changeset
181 if len(sourcerev) != 1:
250
79349fd04836 utils: standardizing imported name to hgutil, our_util to util
Daniel Tang <dytang@cs.purdue.edu>
parents: 249
diff changeset
182 raise hgutil.Abort("Sorry, can't find svn parent of a merge revision.")
152
1fde85a10f9e push: Fix the bad implementation that required modifying the dirstate to push.
Augie Fackler <durin42@gmail.com>
parents: 140
diff changeset
183 sourcerev = sourcerev[0]
1fde85a10f9e push: Fix the bad implementation that required modifying the dirstate to push.
Augie Fackler <durin42@gmail.com>
parents: 140
diff changeset
184 if sourcerev.node() != node.nullid:
99
1da7aafdd323 Refactored outgoing_revisions into util where it really belongs.
Augie Fackler <durin42@gmail.com>
parents: 39
diff changeset
185 return outgoing_rev_hashes
124
291925677a9f tag_repo: remove gentags command, extend repo.tags(), HgChangeEditor now takes either repo or repo_path
Luke Opperman <luke@loppear.com>
parents: 115
diff changeset
186
805
a3f727c41c1d Fix breakage introduced by discovery refactoring
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents: 794
diff changeset
187 def outgoing_common_and_heads(repo, reverse_map, sourcerev):
a3f727c41c1d Fix breakage introduced by discovery refactoring
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents: 794
diff changeset
188 """Given a repo and an hg_editor, determines outgoing revisions for the
a3f727c41c1d Fix breakage introduced by discovery refactoring
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents: 794
diff changeset
189 current working copy state. Returns a tuple (common, heads) like
a3f727c41c1d Fix breakage introduced by discovery refactoring
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents: 794
diff changeset
190 discovery.findcommonoutgoing does.
a3f727c41c1d Fix breakage introduced by discovery refactoring
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents: 794
diff changeset
191 """
a3f727c41c1d Fix breakage introduced by discovery refactoring
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents: 794
diff changeset
192 if sourcerev in reverse_map:
a3f727c41c1d Fix breakage introduced by discovery refactoring
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents: 794
diff changeset
193 return ([sourcerev], [sourcerev]) # nothing outgoing
a3f727c41c1d Fix breakage introduced by discovery refactoring
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents: 794
diff changeset
194 sourcecx = repo[sourcerev]
a3f727c41c1d Fix breakage introduced by discovery refactoring
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents: 794
diff changeset
195 while (not sourcecx.node() in reverse_map
a3f727c41c1d Fix breakage introduced by discovery refactoring
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents: 794
diff changeset
196 and sourcecx.node() != node.nullid):
a3f727c41c1d Fix breakage introduced by discovery refactoring
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents: 794
diff changeset
197 ps = sourcecx.parents()
a3f727c41c1d Fix breakage introduced by discovery refactoring
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents: 794
diff changeset
198 if len(ps) != 1:
a3f727c41c1d Fix breakage introduced by discovery refactoring
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents: 794
diff changeset
199 raise hgutil.Abort("Sorry, can't find svn parent of a merge revision.")
a3f727c41c1d Fix breakage introduced by discovery refactoring
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents: 794
diff changeset
200 sourcecx = ps[0]
a3f727c41c1d Fix breakage introduced by discovery refactoring
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents: 794
diff changeset
201 if sourcecx.node() != node.nullid:
a3f727c41c1d Fix breakage introduced by discovery refactoring
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents: 794
diff changeset
202 return ([sourcecx.node()], [sourcerev])
a3f727c41c1d Fix breakage introduced by discovery refactoring
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents: 794
diff changeset
203 return ([sourcerev], [sourcerev]) # nothing outgoing
a3f727c41c1d Fix breakage introduced by discovery refactoring
Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
parents: 794
diff changeset
204
769
cc1d4aa3ba41 configurable substitution for empty commit message (fixes #195)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 764
diff changeset
205 def default_commit_msg(ui):
770
4dfc41b15d9a make the default substition for an empty commit description the empty string
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 769
diff changeset
206 return ui.config('hgsubversion', 'defaultmessage', '')
186
6266ba36ee15 Create patch to make normal output much less verbose…
Dan Villiom Podlaski Christiansen <danchr@cs.au.dk>
parents: 185
diff changeset
207
198
df4611050286 Output consolidation; decrease the ‘Fetching...’ message to debug level.
Dan Villiom Podlaski Christiansen <danchr@cs.au.dk>
parents: 196
diff changeset
208 def describe_commit(ui, h, b):
df4611050286 Output consolidation; decrease the ‘Fetching...’ message to debug level.
Dan Villiom Podlaski Christiansen <danchr@cs.au.dk>
parents: 196
diff changeset
209 ui.note(' committed to "%s" as %s\n' % ((b or 'default'), node.short(h)))
223
330f0b15d417 issue67: mercurial 1.3 util incompatibility with encoding swap
Luke Opperman <luke@loppear.com>
parents: 221
diff changeset
210
330f0b15d417 issue67: mercurial 1.3 util incompatibility with encoding swap
Luke Opperman <luke@loppear.com>
parents: 221
diff changeset
211
330f0b15d417 issue67: mercurial 1.3 util incompatibility with encoding swap
Luke Opperman <luke@loppear.com>
parents: 221
diff changeset
212 def swap_out_encoding(new_encoding="UTF-8"):
281
8ff0b3261b7f util: drop 1.2 support in the encoding swap.
Augie Fackler <durin42@gmail.com>
parents: 275
diff changeset
213 from mercurial import encoding
8ff0b3261b7f util: drop 1.2 support in the encoding swap.
Augie Fackler <durin42@gmail.com>
parents: 275
diff changeset
214 old = encoding.encoding
8ff0b3261b7f util: drop 1.2 support in the encoding swap.
Augie Fackler <durin42@gmail.com>
parents: 275
diff changeset
215 encoding.encoding = new_encoding
223
330f0b15d417 issue67: mercurial 1.3 util incompatibility with encoding swap
Luke Opperman <luke@loppear.com>
parents: 221
diff changeset
216 return old
410
eb524b957345 move aresamefiles() from HgChangeReceiver to util
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 408
diff changeset
217
952
9c3b4f59e7e6 stupid: do not close branch upon branch-wide revert
Patrick Mezard <patrick@mezard.eu>
parents: 951
diff changeset
218 def isancestor(ctx, ancestorctx):
9c3b4f59e7e6 stupid: do not close branch upon branch-wide revert
Patrick Mezard <patrick@mezard.eu>
parents: 951
diff changeset
219 """Return True if ancestorctx is equal or an ancestor of ctx."""
9c3b4f59e7e6 stupid: do not close branch upon branch-wide revert
Patrick Mezard <patrick@mezard.eu>
parents: 951
diff changeset
220 if ctx == ancestorctx:
9c3b4f59e7e6 stupid: do not close branch upon branch-wide revert
Patrick Mezard <patrick@mezard.eu>
parents: 951
diff changeset
221 return True
9c3b4f59e7e6 stupid: do not close branch upon branch-wide revert
Patrick Mezard <patrick@mezard.eu>
parents: 951
diff changeset
222 for actx in ctx.ancestors():
9c3b4f59e7e6 stupid: do not close branch upon branch-wide revert
Patrick Mezard <patrick@mezard.eu>
parents: 951
diff changeset
223 if actx == ancestorctx:
9c3b4f59e7e6 stupid: do not close branch upon branch-wide revert
Patrick Mezard <patrick@mezard.eu>
parents: 951
diff changeset
224 return True
9c3b4f59e7e6 stupid: do not close branch upon branch-wide revert
Patrick Mezard <patrick@mezard.eu>
parents: 951
diff changeset
225 return False
410
eb524b957345 move aresamefiles() from HgChangeReceiver to util
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 408
diff changeset
226
497
cad864ed29de util: make aresamefiles take one file and just be issamefile instead.
Augie Fackler <durin42@gmail.com>
parents: 475
diff changeset
227 def issamefile(parentctx, childctx, f):
582
44c56a7727c4 editor: fix issamefile() and copy detection in replay mode
Patrick Mezard <pmezard@gmail.com>
parents: 580
diff changeset
228 """Return True if f exists and is the same in childctx and parentctx"""
44c56a7727c4 editor: fix issamefile() and copy detection in replay mode
Patrick Mezard <pmezard@gmail.com>
parents: 580
diff changeset
229 if f not in parentctx or f not in childctx:
44c56a7727c4 editor: fix issamefile() and copy detection in replay mode
Patrick Mezard <pmezard@gmail.com>
parents: 580
diff changeset
230 return False
410
eb524b957345 move aresamefiles() from HgChangeReceiver to util
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 408
diff changeset
231 if parentctx == childctx:
eb524b957345 move aresamefiles() from HgChangeReceiver to util
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 408
diff changeset
232 return True
eb524b957345 move aresamefiles() from HgChangeReceiver to util
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 408
diff changeset
233 if parentctx.rev() > childctx.rev():
eb524b957345 move aresamefiles() from HgChangeReceiver to util
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 408
diff changeset
234 parentctx, childctx = childctx, parentctx
eb524b957345 move aresamefiles() from HgChangeReceiver to util
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 408
diff changeset
235
eb524b957345 move aresamefiles() from HgChangeReceiver to util
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 408
diff changeset
236 def selfandancestors(selfctx):
eb524b957345 move aresamefiles() from HgChangeReceiver to util
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 408
diff changeset
237 yield selfctx
eb524b957345 move aresamefiles() from HgChangeReceiver to util
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 408
diff changeset
238 for ctx in selfctx.ancestors():
eb524b957345 move aresamefiles() from HgChangeReceiver to util
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 408
diff changeset
239 yield ctx
eb524b957345 move aresamefiles() from HgChangeReceiver to util
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 408
diff changeset
240
eb524b957345 move aresamefiles() from HgChangeReceiver to util
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 408
diff changeset
241 for pctx in selfandancestors(childctx):
eb524b957345 move aresamefiles() from HgChangeReceiver to util
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 408
diff changeset
242 if pctx.rev() <= parentctx.rev():
eb524b957345 move aresamefiles() from HgChangeReceiver to util
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 408
diff changeset
243 return True
497
cad864ed29de util: make aresamefiles take one file and just be issamefile instead.
Augie Fackler <durin42@gmail.com>
parents: 475
diff changeset
244 if f in pctx.files():
cad864ed29de util: make aresamefiles take one file and just be issamefile instead.
Augie Fackler <durin42@gmail.com>
parents: 475
diff changeset
245 return False
410
eb524b957345 move aresamefiles() from HgChangeReceiver to util
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 408
diff changeset
246 # parentctx is not an ancestor of childctx, files are unrelated
eb524b957345 move aresamefiles() from HgChangeReceiver to util
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 408
diff changeset
247 return False
707
cb32d90f915e templatekw: clean up implementation & test; add help.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 620
diff changeset
248
884
1b261e0f85aa Abstract away the details of where svn revs are stored in a commit
Bryan O'Sullivan <bryano@fb.com>
parents: 832
diff changeset
249
1b261e0f85aa Abstract away the details of where svn revs are stored in a commit
Bryan O'Sullivan <bryano@fb.com>
parents: 832
diff changeset
250 def getsvnrev(ctx, defval=None):
1b261e0f85aa Abstract away the details of where svn revs are stored in a commit
Bryan O'Sullivan <bryano@fb.com>
parents: 832
diff changeset
251 '''Extract SVN revision from commit metadata'''
1b261e0f85aa Abstract away the details of where svn revs are stored in a commit
Bryan O'Sullivan <bryano@fb.com>
parents: 832
diff changeset
252 return ctx.extra().get('convert_revision', defval)
1b261e0f85aa Abstract away the details of where svn revs are stored in a commit
Bryan O'Sullivan <bryano@fb.com>
parents: 832
diff changeset
253
1b261e0f85aa Abstract away the details of where svn revs are stored in a commit
Bryan O'Sullivan <bryano@fb.com>
parents: 832
diff changeset
254
707
cb32d90f915e templatekw: clean up implementation & test; add help.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 620
diff changeset
255 def _templatehelper(ctx, kw):
cb32d90f915e templatekw: clean up implementation & test; add help.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 620
diff changeset
256 '''
cb32d90f915e templatekw: clean up implementation & test; add help.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 620
diff changeset
257 Helper function for displaying information about converted changesets.
cb32d90f915e templatekw: clean up implementation & test; add help.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 620
diff changeset
258 '''
884
1b261e0f85aa Abstract away the details of where svn revs are stored in a commit
Bryan O'Sullivan <bryano@fb.com>
parents: 832
diff changeset
259 convertinfo = getsvnrev(ctx, '')
707
cb32d90f915e templatekw: clean up implementation & test; add help.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 620
diff changeset
260
cb32d90f915e templatekw: clean up implementation & test; add help.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 620
diff changeset
261 if not convertinfo or not convertinfo.startswith('svn:'):
cb32d90f915e templatekw: clean up implementation & test; add help.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 620
diff changeset
262 return ''
cb32d90f915e templatekw: clean up implementation & test; add help.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 620
diff changeset
263
cb32d90f915e templatekw: clean up implementation & test; add help.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 620
diff changeset
264 if kw == 'svnuuid':
cb32d90f915e templatekw: clean up implementation & test; add help.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 620
diff changeset
265 return convertinfo[4:40]
cb32d90f915e templatekw: clean up implementation & test; add help.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 620
diff changeset
266 elif kw == 'svnpath':
cb32d90f915e templatekw: clean up implementation & test; add help.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 620
diff changeset
267 return convertinfo[40:].rsplit('@', 1)[0]
cb32d90f915e templatekw: clean up implementation & test; add help.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 620
diff changeset
268 elif kw == 'svnrev':
cb32d90f915e templatekw: clean up implementation & test; add help.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 620
diff changeset
269 return convertinfo[40:].rsplit('@', 1)[-1]
cb32d90f915e templatekw: clean up implementation & test; add help.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 620
diff changeset
270 else:
cb32d90f915e templatekw: clean up implementation & test; add help.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 620
diff changeset
271 raise hgutil.Abort('unrecognized hgsubversion keyword %s' % kw)
cb32d90f915e templatekw: clean up implementation & test; add help.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 620
diff changeset
272
794
c32c92fdca5b util: use real function definitions for keywords, document them
Patrick Mezard <pmezard@gmail.com>
parents: 770
diff changeset
273 def svnrevkw(**args):
c32c92fdca5b util: use real function definitions for keywords, document them
Patrick Mezard <pmezard@gmail.com>
parents: 770
diff changeset
274 """:svnrev: String. Converted subversion revision number."""
c32c92fdca5b util: use real function definitions for keywords, document them
Patrick Mezard <pmezard@gmail.com>
parents: 770
diff changeset
275 return _templatehelper(args['ctx'], 'svnrev')
c32c92fdca5b util: use real function definitions for keywords, document them
Patrick Mezard <pmezard@gmail.com>
parents: 770
diff changeset
276
c32c92fdca5b util: use real function definitions for keywords, document them
Patrick Mezard <pmezard@gmail.com>
parents: 770
diff changeset
277 def svnpathkw(**args):
c32c92fdca5b util: use real function definitions for keywords, document them
Patrick Mezard <pmezard@gmail.com>
parents: 770
diff changeset
278 """:svnpath: String. Converted subversion revision project path."""
c32c92fdca5b util: use real function definitions for keywords, document them
Patrick Mezard <pmezard@gmail.com>
parents: 770
diff changeset
279 return _templatehelper(args['ctx'], 'svnpath')
c32c92fdca5b util: use real function definitions for keywords, document them
Patrick Mezard <pmezard@gmail.com>
parents: 770
diff changeset
280
c32c92fdca5b util: use real function definitions for keywords, document them
Patrick Mezard <pmezard@gmail.com>
parents: 770
diff changeset
281 def svnuuidkw(**args):
c32c92fdca5b util: use real function definitions for keywords, document them
Patrick Mezard <pmezard@gmail.com>
parents: 770
diff changeset
282 """:svnuuid: String. Converted subversion revision repository identifier."""
c32c92fdca5b util: use real function definitions for keywords, document them
Patrick Mezard <pmezard@gmail.com>
parents: 770
diff changeset
283 return _templatehelper(args['ctx'], 'svnuuid')
c32c92fdca5b util: use real function definitions for keywords, document them
Patrick Mezard <pmezard@gmail.com>
parents: 770
diff changeset
284
707
cb32d90f915e templatekw: clean up implementation & test; add help.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 620
diff changeset
285 templatekeywords = {
794
c32c92fdca5b util: use real function definitions for keywords, document them
Patrick Mezard <pmezard@gmail.com>
parents: 770
diff changeset
286 'svnrev': svnrevkw,
c32c92fdca5b util: use real function definitions for keywords, document them
Patrick Mezard <pmezard@gmail.com>
parents: 770
diff changeset
287 'svnpath': svnpathkw,
c32c92fdca5b util: use real function definitions for keywords, document them
Patrick Mezard <pmezard@gmail.com>
parents: 770
diff changeset
288 'svnuuid': svnuuidkw,
707
cb32d90f915e templatekw: clean up implementation & test; add help.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 620
diff changeset
289 }
722
aa24148a7454 uisetup: add fromsvn() and svnrev() revsets.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 707
diff changeset
290
aa24148a7454 uisetup: add fromsvn() and svnrev() revsets.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 707
diff changeset
291 def revset_fromsvn(repo, subset, x):
752
bb64ad4ce982 revsets: add docstrings.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 722
diff changeset
292 '''``fromsvn()``
bb64ad4ce982 revsets: add docstrings.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 722
diff changeset
293 Select changesets that originate from Subversion.
bb64ad4ce982 revsets: add docstrings.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 722
diff changeset
294 '''
722
aa24148a7454 uisetup: add fromsvn() and svnrev() revsets.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 707
diff changeset
295 args = revset.getargs(x, 0, 0, "fromsvn takes no arguments")
aa24148a7454 uisetup: add fromsvn() and svnrev() revsets.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 707
diff changeset
296
889
7a98fbadcae9 revsets: huge speedups for fromsvn and svnrev
Bryan O'Sullivan <bryano@fb.com>
parents: 884
diff changeset
297 rev = repo.changelog.rev
7a98fbadcae9 revsets: huge speedups for fromsvn and svnrev
Bryan O'Sullivan <bryano@fb.com>
parents: 884
diff changeset
298 bin = node.bin
7a98fbadcae9 revsets: huge speedups for fromsvn and svnrev
Bryan O'Sullivan <bryano@fb.com>
parents: 884
diff changeset
299 try:
7a98fbadcae9 revsets: huge speedups for fromsvn and svnrev
Bryan O'Sullivan <bryano@fb.com>
parents: 884
diff changeset
300 svnrevs = set(rev(bin(l.split(' ', 2)[1]))
7a98fbadcae9 revsets: huge speedups for fromsvn and svnrev
Bryan O'Sullivan <bryano@fb.com>
parents: 884
diff changeset
301 for l in maps.RevMap.readmapfile(repo, missingok=False))
7a98fbadcae9 revsets: huge speedups for fromsvn and svnrev
Bryan O'Sullivan <bryano@fb.com>
parents: 884
diff changeset
302 return filter(svnrevs.__contains__, subset)
7a98fbadcae9 revsets: huge speedups for fromsvn and svnrev
Bryan O'Sullivan <bryano@fb.com>
parents: 884
diff changeset
303 except IOError, err:
7a98fbadcae9 revsets: huge speedups for fromsvn and svnrev
Bryan O'Sullivan <bryano@fb.com>
parents: 884
diff changeset
304 if err.errno != errno.ENOENT:
7a98fbadcae9 revsets: huge speedups for fromsvn and svnrev
Bryan O'Sullivan <bryano@fb.com>
parents: 884
diff changeset
305 raise
7a98fbadcae9 revsets: huge speedups for fromsvn and svnrev
Bryan O'Sullivan <bryano@fb.com>
parents: 884
diff changeset
306 raise hgutil.Abort("svn metadata is missing - "
7a98fbadcae9 revsets: huge speedups for fromsvn and svnrev
Bryan O'Sullivan <bryano@fb.com>
parents: 884
diff changeset
307 "run 'hg svn rebuildmeta' to reconstruct it")
722
aa24148a7454 uisetup: add fromsvn() and svnrev() revsets.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 707
diff changeset
308
aa24148a7454 uisetup: add fromsvn() and svnrev() revsets.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 707
diff changeset
309 def revset_svnrev(repo, subset, x):
752
bb64ad4ce982 revsets: add docstrings.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 722
diff changeset
310 '''``svnrev(number)``
bb64ad4ce982 revsets: add docstrings.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 722
diff changeset
311 Select changesets that originate in the given Subversion revision.
bb64ad4ce982 revsets: add docstrings.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 722
diff changeset
312 '''
722
aa24148a7454 uisetup: add fromsvn() and svnrev() revsets.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 707
diff changeset
313 args = revset.getargs(x, 1, 1, "svnrev takes one argument")
aa24148a7454 uisetup: add fromsvn() and svnrev() revsets.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 707
diff changeset
314
aa24148a7454 uisetup: add fromsvn() and svnrev() revsets.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 707
diff changeset
315 rev = revset.getstring(args[0],
aa24148a7454 uisetup: add fromsvn() and svnrev() revsets.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 707
diff changeset
316 "the argument to svnrev() must be a number")
aa24148a7454 uisetup: add fromsvn() and svnrev() revsets.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 707
diff changeset
317 try:
889
7a98fbadcae9 revsets: huge speedups for fromsvn and svnrev
Bryan O'Sullivan <bryano@fb.com>
parents: 884
diff changeset
318 revnum = int(rev)
722
aa24148a7454 uisetup: add fromsvn() and svnrev() revsets.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 707
diff changeset
319 except ValueError:
aa24148a7454 uisetup: add fromsvn() and svnrev() revsets.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 707
diff changeset
320 raise error.ParseError("the argument to svnrev() must be a number")
aa24148a7454 uisetup: add fromsvn() and svnrev() revsets.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 707
diff changeset
321
889
7a98fbadcae9 revsets: huge speedups for fromsvn and svnrev
Bryan O'Sullivan <bryano@fb.com>
parents: 884
diff changeset
322 rev = rev + ' '
7a98fbadcae9 revsets: huge speedups for fromsvn and svnrev
Bryan O'Sullivan <bryano@fb.com>
parents: 884
diff changeset
323 revs = []
7a98fbadcae9 revsets: huge speedups for fromsvn and svnrev
Bryan O'Sullivan <bryano@fb.com>
parents: 884
diff changeset
324 try:
7a98fbadcae9 revsets: huge speedups for fromsvn and svnrev
Bryan O'Sullivan <bryano@fb.com>
parents: 884
diff changeset
325 for l in maps.RevMap.readmapfile(repo, missingok=False):
7a98fbadcae9 revsets: huge speedups for fromsvn and svnrev
Bryan O'Sullivan <bryano@fb.com>
parents: 884
diff changeset
326 if l.startswith(rev):
7a98fbadcae9 revsets: huge speedups for fromsvn and svnrev
Bryan O'Sullivan <bryano@fb.com>
parents: 884
diff changeset
327 n = l.split(' ', 2)[1]
7a98fbadcae9 revsets: huge speedups for fromsvn and svnrev
Bryan O'Sullivan <bryano@fb.com>
parents: 884
diff changeset
328 r = repo[node.bin(n)].rev()
7a98fbadcae9 revsets: huge speedups for fromsvn and svnrev
Bryan O'Sullivan <bryano@fb.com>
parents: 884
diff changeset
329 if r in subset:
7a98fbadcae9 revsets: huge speedups for fromsvn and svnrev
Bryan O'Sullivan <bryano@fb.com>
parents: 884
diff changeset
330 revs.append(r)
7a98fbadcae9 revsets: huge speedups for fromsvn and svnrev
Bryan O'Sullivan <bryano@fb.com>
parents: 884
diff changeset
331 return revs
7a98fbadcae9 revsets: huge speedups for fromsvn and svnrev
Bryan O'Sullivan <bryano@fb.com>
parents: 884
diff changeset
332 except IOError, err:
7a98fbadcae9 revsets: huge speedups for fromsvn and svnrev
Bryan O'Sullivan <bryano@fb.com>
parents: 884
diff changeset
333 if err.errno != errno.ENOENT:
7a98fbadcae9 revsets: huge speedups for fromsvn and svnrev
Bryan O'Sullivan <bryano@fb.com>
parents: 884
diff changeset
334 raise
7a98fbadcae9 revsets: huge speedups for fromsvn and svnrev
Bryan O'Sullivan <bryano@fb.com>
parents: 884
diff changeset
335 raise hgutil.Abort("svn metadata is missing - "
7a98fbadcae9 revsets: huge speedups for fromsvn and svnrev
Bryan O'Sullivan <bryano@fb.com>
parents: 884
diff changeset
336 "run 'hg svn rebuildmeta' to reconstruct it")
722
aa24148a7454 uisetup: add fromsvn() and svnrev() revsets.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 707
diff changeset
337
aa24148a7454 uisetup: add fromsvn() and svnrev() revsets.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 707
diff changeset
338 revsets = {
aa24148a7454 uisetup: add fromsvn() and svnrev() revsets.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 707
diff changeset
339 'fromsvn': revset_fromsvn,
aa24148a7454 uisetup: add fromsvn() and svnrev() revsets.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 707
diff changeset
340 'svnrev': revset_svnrev,
aa24148a7454 uisetup: add fromsvn() and svnrev() revsets.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 707
diff changeset
341 }
944
d6db289f1548 pull: add hgsubversion.filestoresize to control memory consumption
Patrick Mezard <patrick@mezard.eu>
parents: 889
diff changeset
342
1009
f0bde4bf1f78 revsets: add support for 'r123' revision labels
Matt Mackall <mpm@selenic.com>
parents: 975
diff changeset
343 def revset_stringset(orig, repo, subset, x):
f0bde4bf1f78 revsets: add support for 'r123' revision labels
Matt Mackall <mpm@selenic.com>
parents: 975
diff changeset
344 if x.startswith('r') and x[1:].isdigit():
f0bde4bf1f78 revsets: add support for 'r123' revision labels
Matt Mackall <mpm@selenic.com>
parents: 975
diff changeset
345 return revset_svnrev(repo, subset, ('string', x[1:]))
f0bde4bf1f78 revsets: add support for 'r123' revision labels
Matt Mackall <mpm@selenic.com>
parents: 975
diff changeset
346 return orig
f0bde4bf1f78 revsets: add support for 'r123' revision labels
Matt Mackall <mpm@selenic.com>
parents: 975
diff changeset
347
944
d6db289f1548 pull: add hgsubversion.filestoresize to control memory consumption
Patrick Mezard <patrick@mezard.eu>
parents: 889
diff changeset
348 def getfilestoresize(ui):
d6db289f1548 pull: add hgsubversion.filestoresize to control memory consumption
Patrick Mezard <patrick@mezard.eu>
parents: 889
diff changeset
349 """Return the replay or stupid file memory store size in megabytes or -1"""
d6db289f1548 pull: add hgsubversion.filestoresize to control memory consumption
Patrick Mezard <patrick@mezard.eu>
parents: 889
diff changeset
350 size = ui.configint('hgsubversion', 'filestoresize', 200)
d6db289f1548 pull: add hgsubversion.filestoresize to control memory consumption
Patrick Mezard <patrick@mezard.eu>
parents: 889
diff changeset
351 if size >= 0:
d6db289f1548 pull: add hgsubversion.filestoresize to control memory consumption
Patrick Mezard <patrick@mezard.eu>
parents: 889
diff changeset
352 size = size*(2**20)
d6db289f1548 pull: add hgsubversion.filestoresize to control memory consumption
Patrick Mezard <patrick@mezard.eu>
parents: 889
diff changeset
353 else:
d6db289f1548 pull: add hgsubversion.filestoresize to control memory consumption
Patrick Mezard <patrick@mezard.eu>
parents: 889
diff changeset
354 size = -1
d6db289f1548 pull: add hgsubversion.filestoresize to control memory consumption
Patrick Mezard <patrick@mezard.eu>
parents: 889
diff changeset
355 return size
951
bd9c292665fd editor: add a small changectx cache
Patrick Mezard <patrick@mezard.eu>
parents: 944
diff changeset
356
bd9c292665fd editor: add a small changectx cache
Patrick Mezard <patrick@mezard.eu>
parents: 944
diff changeset
357 # Copy-paste from mercurial.util to avoid having to deal with backward
bd9c292665fd editor: add a small changectx cache
Patrick Mezard <patrick@mezard.eu>
parents: 944
diff changeset
358 # compatibility, plus the cache size is configurable.
bd9c292665fd editor: add a small changectx cache
Patrick Mezard <patrick@mezard.eu>
parents: 944
diff changeset
359 def lrucachefunc(func, size):
bd9c292665fd editor: add a small changectx cache
Patrick Mezard <patrick@mezard.eu>
parents: 944
diff changeset
360 '''cache most recent results of function calls'''
bd9c292665fd editor: add a small changectx cache
Patrick Mezard <patrick@mezard.eu>
parents: 944
diff changeset
361 cache = {}
bd9c292665fd editor: add a small changectx cache
Patrick Mezard <patrick@mezard.eu>
parents: 944
diff changeset
362 order = deque()
bd9c292665fd editor: add a small changectx cache
Patrick Mezard <patrick@mezard.eu>
parents: 944
diff changeset
363 if func.func_code.co_argcount == 1:
bd9c292665fd editor: add a small changectx cache
Patrick Mezard <patrick@mezard.eu>
parents: 944
diff changeset
364 def f(arg):
bd9c292665fd editor: add a small changectx cache
Patrick Mezard <patrick@mezard.eu>
parents: 944
diff changeset
365 if arg not in cache:
bd9c292665fd editor: add a small changectx cache
Patrick Mezard <patrick@mezard.eu>
parents: 944
diff changeset
366 if len(cache) > size:
bd9c292665fd editor: add a small changectx cache
Patrick Mezard <patrick@mezard.eu>
parents: 944
diff changeset
367 del cache[order.popleft()]
bd9c292665fd editor: add a small changectx cache
Patrick Mezard <patrick@mezard.eu>
parents: 944
diff changeset
368 cache[arg] = func(arg)
bd9c292665fd editor: add a small changectx cache
Patrick Mezard <patrick@mezard.eu>
parents: 944
diff changeset
369 else:
bd9c292665fd editor: add a small changectx cache
Patrick Mezard <patrick@mezard.eu>
parents: 944
diff changeset
370 order.remove(arg)
bd9c292665fd editor: add a small changectx cache
Patrick Mezard <patrick@mezard.eu>
parents: 944
diff changeset
371 order.append(arg)
bd9c292665fd editor: add a small changectx cache
Patrick Mezard <patrick@mezard.eu>
parents: 944
diff changeset
372 return cache[arg]
bd9c292665fd editor: add a small changectx cache
Patrick Mezard <patrick@mezard.eu>
parents: 944
diff changeset
373 else:
bd9c292665fd editor: add a small changectx cache
Patrick Mezard <patrick@mezard.eu>
parents: 944
diff changeset
374 def f(*args):
bd9c292665fd editor: add a small changectx cache
Patrick Mezard <patrick@mezard.eu>
parents: 944
diff changeset
375 if args not in cache:
bd9c292665fd editor: add a small changectx cache
Patrick Mezard <patrick@mezard.eu>
parents: 944
diff changeset
376 if len(cache) > size:
bd9c292665fd editor: add a small changectx cache
Patrick Mezard <patrick@mezard.eu>
parents: 944
diff changeset
377 del cache[order.popleft()]
bd9c292665fd editor: add a small changectx cache
Patrick Mezard <patrick@mezard.eu>
parents: 944
diff changeset
378 cache[args] = func(*args)
bd9c292665fd editor: add a small changectx cache
Patrick Mezard <patrick@mezard.eu>
parents: 944
diff changeset
379 else:
bd9c292665fd editor: add a small changectx cache
Patrick Mezard <patrick@mezard.eu>
parents: 944
diff changeset
380 order.remove(args)
bd9c292665fd editor: add a small changectx cache
Patrick Mezard <patrick@mezard.eu>
parents: 944
diff changeset
381 order.append(args)
bd9c292665fd editor: add a small changectx cache
Patrick Mezard <patrick@mezard.eu>
parents: 944
diff changeset
382 return cache[args]
bd9c292665fd editor: add a small changectx cache
Patrick Mezard <patrick@mezard.eu>
parents: 944
diff changeset
383
bd9c292665fd editor: add a small changectx cache
Patrick Mezard <patrick@mezard.eu>
parents: 944
diff changeset
384 return f
974
336f4bce479a consolidate revision parsing
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 973
diff changeset
385
336f4bce479a consolidate revision parsing
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 973
diff changeset
386 def parse_revnum(svnrepo, r):
336f4bce479a consolidate revision parsing
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 973
diff changeset
387 try:
336f4bce479a consolidate revision parsing
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 973
diff changeset
388 return int(r or 0)
336f4bce479a consolidate revision parsing
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 973
diff changeset
389 except ValueError:
975
9ffa1daf7b08 understand 'tip' as meaning Subversion 'HEAD'
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 974
diff changeset
390 if isinstance(r, str) and r.lower() in ('head', 'tip'):
974
336f4bce479a consolidate revision parsing
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 973
diff changeset
391 return svnrepo.last_changed_rev
336f4bce479a consolidate revision parsing
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 973
diff changeset
392 else:
336f4bce479a consolidate revision parsing
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 973
diff changeset
393 # TODO: use error.RepoLookupError when we drop 1.3?
336f4bce479a consolidate revision parsing
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 973
diff changeset
394 raise hgutil.Abort("unknown Subversion revision %r" % r)