Mercurial > hgsubversion
annotate hgsubversion/util.py @ 555:cbd7065e6ab4
util: add parseurl method to abstract away differences between 1.4 and 1.5
author | Augie Fackler <durin42@gmail.com> |
---|---|
date | Sun, 07 Feb 2010 08:43:32 -0600 |
parents | ac9c9e1a8022 |
children | 35529f736fa2 |
rev | line source |
---|---|
440
80909328aef1
move remaining cmdutils into util
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
431
diff
changeset
|
1 import re |
0
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
2 import os |
440
80909328aef1
move remaining cmdutils into util
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
431
diff
changeset
|
3 import urllib |
0
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
4 |
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
|
5 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
|
6 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
|
7 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
|
8 |
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 |
440
80909328aef1
move remaining cmdutils into util
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
431
diff
changeset
|
10 b_re = re.compile(r'^\+\+\+ b\/([^\n]*)', re.MULTILINE) |
80909328aef1
move remaining cmdutils into util
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
431
diff
changeset
|
11 a_re = re.compile(r'^--- a\/([^\n]*)', re.MULTILINE) |
80909328aef1
move remaining cmdutils into util
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
431
diff
changeset
|
12 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
|
13 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
|
14 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
|
15 re.MULTILINE) |
80909328aef1
move remaining cmdutils into util
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
431
diff
changeset
|
16 |
80909328aef1
move remaining cmdutils into util
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
431
diff
changeset
|
17 |
80909328aef1
move remaining cmdutils into util
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
431
diff
changeset
|
18 def formatrev(rev): |
80909328aef1
move remaining cmdutils into util
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
431
diff
changeset
|
19 if rev == -1: |
80909328aef1
move remaining cmdutils into util
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
431
diff
changeset
|
20 return '\t(working copy)' |
80909328aef1
move remaining cmdutils into util
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
431
diff
changeset
|
21 return '\t(revision %d)' % rev |
80909328aef1
move remaining cmdutils into util
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
431
diff
changeset
|
22 |
80909328aef1
move remaining cmdutils into util
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
431
diff
changeset
|
23 |
80909328aef1
move remaining cmdutils into util
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
431
diff
changeset
|
24 def filterdiff(diff, oldrev, newrev): |
80909328aef1
move remaining cmdutils into util
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
431
diff
changeset
|
25 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
|
26 r'+++ \1\t(working copy)', |
80909328aef1
move remaining cmdutils into util
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
431
diff
changeset
|
27 diff) |
80909328aef1
move remaining cmdutils into util
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
431
diff
changeset
|
28 oldrev = formatrev(oldrev) |
80909328aef1
move remaining cmdutils into util
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
431
diff
changeset
|
29 newrev = formatrev(newrev) |
80909328aef1
move remaining cmdutils into util
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
431
diff
changeset
|
30 diff = a_re.sub(r'--- \1'+ oldrev, diff) |
80909328aef1
move remaining cmdutils into util
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
431
diff
changeset
|
31 diff = b_re.sub(r'+++ \1' + newrev, diff) |
80909328aef1
move remaining cmdutils into util
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
431
diff
changeset
|
32 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
|
33 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
|
34 return diff |
80909328aef1
move remaining cmdutils into util
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
431
diff
changeset
|
35 |
80909328aef1
move remaining cmdutils into util
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
431
diff
changeset
|
36 |
80909328aef1
move remaining cmdutils into util
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
431
diff
changeset
|
37 def parentrev(ui, repo, meta, hashes): |
80909328aef1
move remaining cmdutils into util
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
431
diff
changeset
|
38 """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
|
39 """ |
80909328aef1
move remaining cmdutils into util
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
431
diff
changeset
|
40 workingctx = repo.parents()[0] |
80909328aef1
move remaining cmdutils into util
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
431
diff
changeset
|
41 outrev = outgoing_revisions(repo, hashes, workingctx.node()) |
80909328aef1
move remaining cmdutils into util
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
431
diff
changeset
|
42 if outrev: |
80909328aef1
move remaining cmdutils into util
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
431
diff
changeset
|
43 workingctx = repo[outrev[-1]].parents()[0] |
80909328aef1
move remaining cmdutils into util
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
431
diff
changeset
|
44 return workingctx |
80909328aef1
move remaining cmdutils into util
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
431
diff
changeset
|
45 |
80909328aef1
move remaining cmdutils into util
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
431
diff
changeset
|
46 |
80909328aef1
move remaining cmdutils into util
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
431
diff
changeset
|
47 def islocalrepo(url): |
80909328aef1
move remaining cmdutils into util
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
431
diff
changeset
|
48 if not url.startswith('file:///'): |
80909328aef1
move remaining cmdutils into util
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
431
diff
changeset
|
49 return False |
80909328aef1
move remaining cmdutils into util
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
431
diff
changeset
|
50 if '#' in url.split('/')[-1]: # strip off #anchor |
80909328aef1
move remaining cmdutils into util
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
431
diff
changeset
|
51 url = url[:url.rfind('#')] |
80909328aef1
move remaining cmdutils into util
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
431
diff
changeset
|
52 path = url[len('file://'):] |
80909328aef1
move remaining cmdutils into util
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
431
diff
changeset
|
53 path = urllib.url2pathname(path).replace(os.sep, '/') |
80909328aef1
move remaining cmdutils into util
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
431
diff
changeset
|
54 while '/' in path: |
80909328aef1
move remaining cmdutils into util
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
431
diff
changeset
|
55 if reduce(lambda x,y: x and y, |
80909328aef1
move remaining cmdutils into util
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
431
diff
changeset
|
56 map(lambda p: os.path.exists(os.path.join(path, p)), |
80909328aef1
move remaining cmdutils into util
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
431
diff
changeset
|
57 ('hooks', 'format', 'db', ))): |
80909328aef1
move remaining cmdutils into util
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
431
diff
changeset
|
58 return True |
80909328aef1
move remaining cmdutils into util
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
431
diff
changeset
|
59 path = path.rsplit('/', 1)[0] |
80909328aef1
move remaining cmdutils into util
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
431
diff
changeset
|
60 return False |
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 |
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
|
63 def version(ui): |
509
ac9c9e1a8022
setup: write out version info
Augie Fackler <durin42@gmail.com>
parents:
497
diff
changeset
|
64 """Return version information if available.""" |
ac9c9e1a8022
setup: write out version info
Augie Fackler <durin42@gmail.com>
parents:
497
diff
changeset
|
65 try: |
ac9c9e1a8022
setup: write out version info
Augie Fackler <durin42@gmail.com>
parents:
497
diff
changeset
|
66 import __version__ |
ac9c9e1a8022
setup: write out version info
Augie Fackler <durin42@gmail.com>
parents:
497
diff
changeset
|
67 return __version__.version |
ac9c9e1a8022
setup: write out version info
Augie Fackler <durin42@gmail.com>
parents:
497
diff
changeset
|
68 except ImportError: |
ac9c9e1a8022
setup: write out version info
Augie Fackler <durin42@gmail.com>
parents:
497
diff
changeset
|
69 try: |
ac9c9e1a8022
setup: write out version info
Augie Fackler <durin42@gmail.com>
parents:
497
diff
changeset
|
70 dn = os.path.dirname |
ac9c9e1a8022
setup: write out version info
Augie Fackler <durin42@gmail.com>
parents:
497
diff
changeset
|
71 repo = hg.repository(ui, dn(dn(__file__))) |
ac9c9e1a8022
setup: write out version info
Augie Fackler <durin42@gmail.com>
parents:
497
diff
changeset
|
72 ver = repo.dirstate.parents()[0] |
ac9c9e1a8022
setup: write out version info
Augie Fackler <durin42@gmail.com>
parents:
497
diff
changeset
|
73 return node.hex(ver)[:12] |
ac9c9e1a8022
setup: write out version info
Augie Fackler <durin42@gmail.com>
parents:
497
diff
changeset
|
74 except: |
ac9c9e1a8022
setup: write out version info
Augie Fackler <durin42@gmail.com>
parents:
497
diff
changeset
|
75 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
|
76 |
0
f2636cfed115
Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
77 |
469
5567af673f83
Revive svn+http(s) URLs support (issue94)
Patrick Mezard <pmezard@gmail.com>
parents:
465
diff
changeset
|
78 def normalize_url(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
|
79 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
|
80 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
|
81 url, revs, checkout = parseurl(url) |
284
f8f9a2993705
Implement parseurl support (#revision in repository urls)
Martijn Pieters <mj@zopatista.com>
parents:
281
diff
changeset
|
82 url = url.rstrip('/') |
f8f9a2993705
Implement parseurl support (#revision in repository urls)
Martijn Pieters <mj@zopatista.com>
parents:
281
diff
changeset
|
83 if checkout: |
f8f9a2993705
Implement parseurl support (#revision in repository urls)
Martijn Pieters <mj@zopatista.com>
parents:
281
diff
changeset
|
84 url = '%s#%s' % (url, checkout) |
f8f9a2993705
Implement parseurl support (#revision in repository urls)
Martijn Pieters <mj@zopatista.com>
parents:
281
diff
changeset
|
85 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
|
86 |
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
|
87 |
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
|
88 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
|
89 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
|
90 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
|
91 # 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
|
92 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
|
93 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
|
94 svn_url, heads = 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
|
95 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
|
96 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
|
97 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
|
98 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
|
99 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
|
100 |
cbd7065e6ab4
util: add parseurl method to abstract away differences between 1.4 and 1.5
Augie Fackler <durin42@gmail.com>
parents:
509
diff
changeset
|
101 |
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
|
102 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
|
103 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
|
104 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
|
105 |
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
|
106 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
|
107 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
|
108 |
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
|
109 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
|
110 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
|
111 |
416
cd6317fe70be
invert the svnmeta/editor relationship
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
410
diff
changeset
|
112 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
|
113 """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
|
114 current working copy state. |
1da7aafdd323
Refactored outgoing_revisions into util where it really belongs.
Augie Fackler <durin42@gmail.com>
parents:
39
diff
changeset
|
115 """ |
1da7aafdd323
Refactored outgoing_revisions into util where it really belongs.
Augie Fackler <durin42@gmail.com>
parents:
39
diff
changeset
|
116 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
|
117 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
|
118 return |
152
1fde85a10f9e
push: Fix the bad implementation that required modifying the dirstate to push.
Augie Fackler <durin42@gmail.com>
parents:
140
diff
changeset
|
119 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
|
120 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
|
121 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
|
122 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
|
123 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
|
124 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
|
125 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
|
126 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
|
127 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
|
128 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
|
129 |
186
6266ba36ee15
Create patch to make normal output much less verbose…
Dan Villiom Podlaski Christiansen <danchr@cs.au.dk>
parents:
185
diff
changeset
|
130 default_commit_msg = '*** empty log message ***' |
6266ba36ee15
Create patch to make normal output much less verbose…
Dan Villiom Podlaski Christiansen <danchr@cs.au.dk>
parents:
185
diff
changeset
|
131 |
198
df4611050286
Output consolidation; decrease the ‘Fetching...’ message to debug level.
Dan Villiom Podlaski Christiansen <danchr@cs.au.dk>
parents:
196
diff
changeset
|
132 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
|
133 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
|
134 |
330f0b15d417
issue67: mercurial 1.3 util incompatibility with encoding swap
Luke Opperman <luke@loppear.com>
parents:
221
diff
changeset
|
135 |
330f0b15d417
issue67: mercurial 1.3 util incompatibility with encoding swap
Luke Opperman <luke@loppear.com>
parents:
221
diff
changeset
|
136 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
|
137 from mercurial import encoding |
8ff0b3261b7f
util: drop 1.2 support in the encoding swap.
Augie Fackler <durin42@gmail.com>
parents:
275
diff
changeset
|
138 old = encoding.encoding |
8ff0b3261b7f
util: drop 1.2 support in the encoding swap.
Augie Fackler <durin42@gmail.com>
parents:
275
diff
changeset
|
139 encoding.encoding = new_encoding |
223
330f0b15d417
issue67: mercurial 1.3 util incompatibility with encoding swap
Luke Opperman <luke@loppear.com>
parents:
221
diff
changeset
|
140 return old |
410
eb524b957345
move aresamefiles() from HgChangeReceiver to util
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
408
diff
changeset
|
141 |
eb524b957345
move aresamefiles() from HgChangeReceiver to util
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
408
diff
changeset
|
142 |
497
cad864ed29de
util: make aresamefiles take one file and just be issamefile instead.
Augie Fackler <durin42@gmail.com>
parents:
475
diff
changeset
|
143 def issamefile(parentctx, childctx, f): |
cad864ed29de
util: make aresamefiles take one file and just be issamefile instead.
Augie Fackler <durin42@gmail.com>
parents:
475
diff
changeset
|
144 """Assuming f exists and is the same in childctx and parentctx, return True.""" |
410
eb524b957345
move aresamefiles() from HgChangeReceiver to util
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
408
diff
changeset
|
145 if parentctx == childctx: |
eb524b957345
move aresamefiles() from HgChangeReceiver to util
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
408
diff
changeset
|
146 return True |
eb524b957345
move aresamefiles() from HgChangeReceiver to util
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
408
diff
changeset
|
147 if parentctx.rev() > childctx.rev(): |
eb524b957345
move aresamefiles() from HgChangeReceiver to util
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
408
diff
changeset
|
148 parentctx, childctx = childctx, parentctx |
eb524b957345
move aresamefiles() from HgChangeReceiver to util
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
408
diff
changeset
|
149 |
eb524b957345
move aresamefiles() from HgChangeReceiver to util
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
408
diff
changeset
|
150 def selfandancestors(selfctx): |
eb524b957345
move aresamefiles() from HgChangeReceiver to util
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
408
diff
changeset
|
151 yield selfctx |
eb524b957345
move aresamefiles() from HgChangeReceiver to util
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
408
diff
changeset
|
152 for ctx in selfctx.ancestors(): |
eb524b957345
move aresamefiles() from HgChangeReceiver to util
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
408
diff
changeset
|
153 yield ctx |
eb524b957345
move aresamefiles() from HgChangeReceiver to util
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
408
diff
changeset
|
154 |
eb524b957345
move aresamefiles() from HgChangeReceiver to util
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
408
diff
changeset
|
155 for pctx in selfandancestors(childctx): |
eb524b957345
move aresamefiles() from HgChangeReceiver to util
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
408
diff
changeset
|
156 if pctx.rev() <= parentctx.rev(): |
eb524b957345
move aresamefiles() from HgChangeReceiver to util
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
408
diff
changeset
|
157 return True |
497
cad864ed29de
util: make aresamefiles take one file and just be issamefile instead.
Augie Fackler <durin42@gmail.com>
parents:
475
diff
changeset
|
158 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
|
159 return False |
410
eb524b957345
move aresamefiles() from HgChangeReceiver to util
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
408
diff
changeset
|
160 # 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
|
161 return False |