annotate hgsubversion/svncommands.py @ 384:26337d097e18

Remove defunct nourl lists.
author Augie Fackler <durin42@gmail.com>
date Sat, 30 May 2009 15:34:29 -0500
parents 987bd7444f60
children 636e9bf5d49c
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
241
4950b18cf949 Move fetch_command.fetch_revisions() to svncommands.pull().
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff changeset
1 import os
246
074f27c68818 Move rebuildmeta into svncommands.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 244
diff changeset
2 import cPickle as pickle
241
4950b18cf949 Move fetch_command.fetch_revisions() to svncommands.pull().
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff changeset
3
242
06130689a2c8 Move push into svncommands.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 241
diff changeset
4 from mercurial import hg
06130689a2c8 Move push into svncommands.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 241
diff changeset
5 from mercurial import node
241
4950b18cf949 Move fetch_command.fetch_revisions() to svncommands.pull().
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff changeset
6 from mercurial import util as hgutil
242
06130689a2c8 Move push into svncommands.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 241
diff changeset
7
241
4950b18cf949 Move fetch_command.fetch_revisions() to svncommands.pull().
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff changeset
8
4950b18cf949 Move fetch_command.fetch_revisions() to svncommands.pull().
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff changeset
9 import hg_delta_editor
4950b18cf949 Move fetch_command.fetch_revisions() to svncommands.pull().
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff changeset
10 import svnwrap
4950b18cf949 Move fetch_command.fetch_revisions() to svncommands.pull().
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff changeset
11 import util
242
06130689a2c8 Move push into svncommands.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 241
diff changeset
12 import utility_commands
291
ba8e91a7c077 Add 'updateexternals' to synchronize externals with remote repo.
Patrick Mezard <pmezard@gmail.com>
parents: 274
diff changeset
13 import svnexternals
241
4950b18cf949 Move fetch_command.fetch_revisions() to svncommands.pull().
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff changeset
14
4950b18cf949 Move fetch_command.fetch_revisions() to svncommands.pull().
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff changeset
15
255
246aaefb1cc0 Add a basic incoming command.
Nat Williams <nat.williams@gmail.com>
parents: 253
diff changeset
16 def incoming(ui, svn_url, hg_repo_path, skipto_rev=0, stupid=None,
246aaefb1cc0 Add a basic incoming command.
Nat Williams <nat.williams@gmail.com>
parents: 253
diff changeset
17 tag_locations='tags', authors=None, filemap=None, **opts):
246aaefb1cc0 Add a basic incoming command.
Nat Williams <nat.williams@gmail.com>
parents: 253
diff changeset
18 """show incoming revisions from Subversion
246aaefb1cc0 Add a basic incoming command.
Nat Williams <nat.williams@gmail.com>
parents: 253
diff changeset
19 """
246aaefb1cc0 Add a basic incoming command.
Nat Williams <nat.williams@gmail.com>
parents: 253
diff changeset
20 svn_url = util.normalize_url(svn_url)
246aaefb1cc0 Add a basic incoming command.
Nat Williams <nat.williams@gmail.com>
parents: 253
diff changeset
21
246aaefb1cc0 Add a basic incoming command.
Nat Williams <nat.williams@gmail.com>
parents: 253
diff changeset
22 initializing_repo = False
265
9f0738587f94 Re-re-refix username support, add a comment so maybe I remember this time.
Augie Fackler <durin42@gmail.com>
parents: 257
diff changeset
23 user, passwd = util.getuserpass(opts)
255
246aaefb1cc0 Add a basic incoming command.
Nat Williams <nat.williams@gmail.com>
parents: 253
diff changeset
24 svn = svnwrap.SubversionRepo(svn_url, user, passwd)
307
1d48d9a34c19 Put authormap into a separate file, and make it much better too.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 291
diff changeset
25 author_host = ui.config('hgsubversion', 'defaulthost', svn.uuid)
255
246aaefb1cc0 Add a basic incoming command.
Nat Williams <nat.williams@gmail.com>
parents: 253
diff changeset
26 tag_locations = tag_locations.split(',')
246aaefb1cc0 Add a basic incoming command.
Nat Williams <nat.williams@gmail.com>
parents: 253
diff changeset
27 hg_editor = hg_delta_editor.HgChangeReceiver(hg_repo_path,
246aaefb1cc0 Add a basic incoming command.
Nat Williams <nat.williams@gmail.com>
parents: 253
diff changeset
28 ui_=ui,
246aaefb1cc0 Add a basic incoming command.
Nat Williams <nat.williams@gmail.com>
parents: 253
diff changeset
29 subdir=svn.subdir,
246aaefb1cc0 Add a basic incoming command.
Nat Williams <nat.williams@gmail.com>
parents: 253
diff changeset
30 author_host=author_host,
246aaefb1cc0 Add a basic incoming command.
Nat Williams <nat.williams@gmail.com>
parents: 253
diff changeset
31 tag_locations=tag_locations,
246aaefb1cc0 Add a basic incoming command.
Nat Williams <nat.williams@gmail.com>
parents: 253
diff changeset
32 authors=authors,
331
75f082b5897e Switch to using url scheme wrappers instead of duplicating each command we wrap.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 307
diff changeset
33 filemap=filemap,
75f082b5897e Switch to using url scheme wrappers instead of duplicating each command we wrap.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 307
diff changeset
34 uuid=svn.uuid)
75f082b5897e Switch to using url scheme wrappers instead of duplicating each command we wrap.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 307
diff changeset
35 start = max(hg_editor.last_known_revision(), skipto_rev)
75f082b5897e Switch to using url scheme wrappers instead of duplicating each command we wrap.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 307
diff changeset
36 initializing_repo = (hg_editor.last_known_revision() <= 0)
255
246aaefb1cc0 Add a basic incoming command.
Nat Williams <nat.williams@gmail.com>
parents: 253
diff changeset
37
246aaefb1cc0 Add a basic incoming command.
Nat Williams <nat.williams@gmail.com>
parents: 253
diff changeset
38 if initializing_repo and start > 0:
246aaefb1cc0 Add a basic incoming command.
Nat Williams <nat.williams@gmail.com>
parents: 253
diff changeset
39 raise hgutil.Abort('Revision skipping at repository initialization '
246aaefb1cc0 Add a basic incoming command.
Nat Williams <nat.williams@gmail.com>
parents: 253
diff changeset
40 'remains unimplemented.')
246aaefb1cc0 Add a basic incoming command.
Nat Williams <nat.williams@gmail.com>
parents: 253
diff changeset
41
246aaefb1cc0 Add a basic incoming command.
Nat Williams <nat.williams@gmail.com>
parents: 253
diff changeset
42 rev_stuff = (('revision', 'revnum'),
246aaefb1cc0 Add a basic incoming command.
Nat Williams <nat.williams@gmail.com>
parents: 253
diff changeset
43 ('user', 'author'),
246aaefb1cc0 Add a basic incoming command.
Nat Williams <nat.williams@gmail.com>
parents: 253
diff changeset
44 ('date', 'date'),
246aaefb1cc0 Add a basic incoming command.
Nat Williams <nat.williams@gmail.com>
parents: 253
diff changeset
45 ('message', 'message')
246aaefb1cc0 Add a basic incoming command.
Nat Williams <nat.williams@gmail.com>
parents: 253
diff changeset
46 )
246aaefb1cc0 Add a basic incoming command.
Nat Williams <nat.williams@gmail.com>
parents: 253
diff changeset
47
246aaefb1cc0 Add a basic incoming command.
Nat Williams <nat.williams@gmail.com>
parents: 253
diff changeset
48 ui.status('incoming changes from %s\n' % svn_url)
246aaefb1cc0 Add a basic incoming command.
Nat Williams <nat.williams@gmail.com>
parents: 253
diff changeset
49
246aaefb1cc0 Add a basic incoming command.
Nat Williams <nat.williams@gmail.com>
parents: 253
diff changeset
50 for r in svn.revisions(start=start):
246aaefb1cc0 Add a basic incoming command.
Nat Williams <nat.williams@gmail.com>
parents: 253
diff changeset
51 ui.status('\n')
246aaefb1cc0 Add a basic incoming command.
Nat Williams <nat.williams@gmail.com>
parents: 253
diff changeset
52 for label, attr in rev_stuff:
246aaefb1cc0 Add a basic incoming command.
Nat Williams <nat.williams@gmail.com>
parents: 253
diff changeset
53 l1 = label+':'
246aaefb1cc0 Add a basic incoming command.
Nat Williams <nat.williams@gmail.com>
parents: 253
diff changeset
54 ui.status('%s%s\n' % (l1.ljust(13),
246aaefb1cc0 Add a basic incoming command.
Nat Williams <nat.williams@gmail.com>
parents: 253
diff changeset
55 str(r.__getattribute__(attr)).strip(), ))
246aaefb1cc0 Add a basic incoming command.
Nat Williams <nat.williams@gmail.com>
parents: 253
diff changeset
56
246aaefb1cc0 Add a basic incoming command.
Nat Williams <nat.williams@gmail.com>
parents: 253
diff changeset
57
246
074f27c68818 Move rebuildmeta into svncommands.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 244
diff changeset
58 def rebuildmeta(ui, repo, hg_repo_path, args, **opts):
074f27c68818 Move rebuildmeta into svncommands.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 244
diff changeset
59 """rebuild hgsubversion metadata using values stored in revisions
074f27c68818 Move rebuildmeta into svncommands.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 244
diff changeset
60 """
074f27c68818 Move rebuildmeta into svncommands.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 244
diff changeset
61 if len(args) != 1:
331
75f082b5897e Switch to using url scheme wrappers instead of duplicating each command we wrap.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 307
diff changeset
62 url = repo.ui.expandpath(dest or 'default-push', dest or 'default')
75f082b5897e Switch to using url scheme wrappers instead of duplicating each command we wrap.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 307
diff changeset
63 else:
75f082b5897e Switch to using url scheme wrappers instead of duplicating each command we wrap.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 307
diff changeset
64 url = args[0]
246
074f27c68818 Move rebuildmeta into svncommands.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 244
diff changeset
65 uuid = None
331
75f082b5897e Switch to using url scheme wrappers instead of duplicating each command we wrap.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 307
diff changeset
66 url = util.normalize_url(url.rstrip('/'))
265
9f0738587f94 Re-re-refix username support, add a comment so maybe I remember this time.
Augie Fackler <durin42@gmail.com>
parents: 257
diff changeset
67 user, passwd = util.getuserpass(opts)
246
074f27c68818 Move rebuildmeta into svncommands.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 244
diff changeset
68 svn = svnwrap.SubversionRepo(url, user, passwd)
074f27c68818 Move rebuildmeta into svncommands.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 244
diff changeset
69 subdir = svn.subdir
074f27c68818 Move rebuildmeta into svncommands.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 244
diff changeset
70 svnmetadir = os.path.join(repo.path, 'svn')
074f27c68818 Move rebuildmeta into svncommands.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 244
diff changeset
71 if not os.path.exists(svnmetadir):
074f27c68818 Move rebuildmeta into svncommands.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 244
diff changeset
72 os.makedirs(svnmetadir)
074f27c68818 Move rebuildmeta into svncommands.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 244
diff changeset
73
074f27c68818 Move rebuildmeta into svncommands.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 244
diff changeset
74 revmap = open(os.path.join(svnmetadir, 'rev_map'), 'w')
074f27c68818 Move rebuildmeta into svncommands.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 244
diff changeset
75 revmap.write('1\n')
074f27c68818 Move rebuildmeta into svncommands.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 244
diff changeset
76 last_rev = -1
074f27c68818 Move rebuildmeta into svncommands.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 244
diff changeset
77 branchinfo = {}
074f27c68818 Move rebuildmeta into svncommands.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 244
diff changeset
78 noderevnums = {}
074f27c68818 Move rebuildmeta into svncommands.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 244
diff changeset
79 for rev in repo:
371
b45671850969 Add some comments for rebuildmeta, simplify a little.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 342
diff changeset
80
246
074f27c68818 Move rebuildmeta into svncommands.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 244
diff changeset
81 ctx = repo[rev]
074f27c68818 Move rebuildmeta into svncommands.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 244
diff changeset
82 convinfo = ctx.extra().get('convert_revision', None)
371
b45671850969 Add some comments for rebuildmeta, simplify a little.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 342
diff changeset
83 if not convinfo:
b45671850969 Add some comments for rebuildmeta, simplify a little.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 342
diff changeset
84 continue
b45671850969 Add some comments for rebuildmeta, simplify a little.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 342
diff changeset
85
b45671850969 Add some comments for rebuildmeta, simplify a little.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 342
diff changeset
86 # check that the conversion metadata matches expectations
b45671850969 Add some comments for rebuildmeta, simplify a little.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 342
diff changeset
87 assert convinfo.startswith('svn:')
b45671850969 Add some comments for rebuildmeta, simplify a little.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 342
diff changeset
88 revpath, revision = convinfo[40:].split('@')
b45671850969 Add some comments for rebuildmeta, simplify a little.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 342
diff changeset
89 if subdir and subdir[0] != '/':
b45671850969 Add some comments for rebuildmeta, simplify a little.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 342
diff changeset
90 subdir = '/' + subdir
b45671850969 Add some comments for rebuildmeta, simplify a little.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 342
diff changeset
91 if subdir and subdir[-1] == '/':
b45671850969 Add some comments for rebuildmeta, simplify a little.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 342
diff changeset
92 subdir = subdir[:-1]
b45671850969 Add some comments for rebuildmeta, simplify a little.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 342
diff changeset
93 assert revpath.startswith(subdir), ('That does not look like the '
b45671850969 Add some comments for rebuildmeta, simplify a little.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 342
diff changeset
94 'right location in the repo.')
b45671850969 Add some comments for rebuildmeta, simplify a little.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 342
diff changeset
95
b45671850969 Add some comments for rebuildmeta, simplify a little.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 342
diff changeset
96 # write repository uuid if required
b45671850969 Add some comments for rebuildmeta, simplify a little.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 342
diff changeset
97 if uuid is None:
b45671850969 Add some comments for rebuildmeta, simplify a little.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 342
diff changeset
98 uuid = convinfo[4:40]
b45671850969 Add some comments for rebuildmeta, simplify a little.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 342
diff changeset
99 assert uuid == svn.uuid, 'UUIDs did not match!'
b45671850969 Add some comments for rebuildmeta, simplify a little.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 342
diff changeset
100 uuidfile = open(os.path.join(svnmetadir, 'uuid'), 'w')
b45671850969 Add some comments for rebuildmeta, simplify a little.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 342
diff changeset
101 uuidfile.write(uuid)
b45671850969 Add some comments for rebuildmeta, simplify a little.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 342
diff changeset
102 uuidfile.close()
b45671850969 Add some comments for rebuildmeta, simplify a little.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 342
diff changeset
103
b45671850969 Add some comments for rebuildmeta, simplify a little.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 342
diff changeset
104 # find commitpath, write to revmap
b45671850969 Add some comments for rebuildmeta, simplify a little.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 342
diff changeset
105 commitpath = revpath[len(subdir)+1:]
b45671850969 Add some comments for rebuildmeta, simplify a little.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 342
diff changeset
106 if commitpath.startswith('branches'):
b45671850969 Add some comments for rebuildmeta, simplify a little.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 342
diff changeset
107 commitpath = commitpath[len('branches/'):]
b45671850969 Add some comments for rebuildmeta, simplify a little.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 342
diff changeset
108 elif commitpath == 'trunk':
b45671850969 Add some comments for rebuildmeta, simplify a little.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 342
diff changeset
109 commitpath = ''
b45671850969 Add some comments for rebuildmeta, simplify a little.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 342
diff changeset
110 else:
b45671850969 Add some comments for rebuildmeta, simplify a little.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 342
diff changeset
111 assert False, 'Unhandled case in rebuildmeta'
b45671850969 Add some comments for rebuildmeta, simplify a little.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 342
diff changeset
112 revmap.write('%s %s %s\n' % (revision, ctx.hex(), commitpath))
b45671850969 Add some comments for rebuildmeta, simplify a little.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 342
diff changeset
113
b45671850969 Add some comments for rebuildmeta, simplify a little.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 342
diff changeset
114 revision = int(revision)
b45671850969 Add some comments for rebuildmeta, simplify a little.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 342
diff changeset
115 noderevnums[ctx.node()] = revision
b45671850969 Add some comments for rebuildmeta, simplify a little.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 342
diff changeset
116 if revision > last_rev:
b45671850969 Add some comments for rebuildmeta, simplify a little.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 342
diff changeset
117 last_rev = revision
375
af9fc01299b4 Make branch closing more Mercurial-like.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 371
diff changeset
118
af9fc01299b4 Make branch closing more Mercurial-like.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 371
diff changeset
119 # deal with branches
af9fc01299b4 Make branch closing more Mercurial-like.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 371
diff changeset
120 if ctx.extra().get('close'): # don't re-add, we just deleted!
af9fc01299b4 Make branch closing more Mercurial-like.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 371
diff changeset
121 continue
371
b45671850969 Add some comments for rebuildmeta, simplify a little.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 342
diff changeset
122 branch = ctx.branch()
b45671850969 Add some comments for rebuildmeta, simplify a little.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 342
diff changeset
123 if branch == 'default':
b45671850969 Add some comments for rebuildmeta, simplify a little.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 342
diff changeset
124 branch = None
b45671850969 Add some comments for rebuildmeta, simplify a little.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 342
diff changeset
125 if branch not in branchinfo:
b45671850969 Add some comments for rebuildmeta, simplify a little.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 342
diff changeset
126 parent = ctx.parents()[0]
b45671850969 Add some comments for rebuildmeta, simplify a little.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 342
diff changeset
127 if (parent.node() in noderevnums
b45671850969 Add some comments for rebuildmeta, simplify a little.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 342
diff changeset
128 and parent.branch() != ctx.branch()):
b45671850969 Add some comments for rebuildmeta, simplify a little.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 342
diff changeset
129 parentbranch = parent.branch()
b45671850969 Add some comments for rebuildmeta, simplify a little.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 342
diff changeset
130 if parentbranch == 'default':
246
074f27c68818 Move rebuildmeta into svncommands.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 244
diff changeset
131 parentbranch = None
371
b45671850969 Add some comments for rebuildmeta, simplify a little.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 342
diff changeset
132 else:
b45671850969 Add some comments for rebuildmeta, simplify a little.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 342
diff changeset
133 parentbranch = None
b45671850969 Add some comments for rebuildmeta, simplify a little.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 342
diff changeset
134 branchinfo[branch] = (parentbranch,
b45671850969 Add some comments for rebuildmeta, simplify a little.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 342
diff changeset
135 noderevnums.get(parent.node(), 0),
b45671850969 Add some comments for rebuildmeta, simplify a little.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 342
diff changeset
136 revision)
b45671850969 Add some comments for rebuildmeta, simplify a little.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 342
diff changeset
137
375
af9fc01299b4 Make branch closing more Mercurial-like.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 371
diff changeset
138 for cctx in ctx.children():
af9fc01299b4 Make branch closing more Mercurial-like.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 371
diff changeset
139 if cctx.extra().get('close'):
371
b45671850969 Add some comments for rebuildmeta, simplify a little.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 342
diff changeset
140 branchinfo.pop(branch, None)
375
af9fc01299b4 Make branch closing more Mercurial-like.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 371
diff changeset
141 break
371
b45671850969 Add some comments for rebuildmeta, simplify a little.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 342
diff changeset
142
b45671850969 Add some comments for rebuildmeta, simplify a little.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 342
diff changeset
143 # save off branch info
246
074f27c68818 Move rebuildmeta into svncommands.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 244
diff changeset
144 branchinfofile = open(os.path.join(svnmetadir, 'branch_info'), 'w')
074f27c68818 Move rebuildmeta into svncommands.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 244
diff changeset
145 pickle.dump(branchinfo, branchinfofile)
074f27c68818 Move rebuildmeta into svncommands.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 244
diff changeset
146 branchinfofile.close()
074f27c68818 Move rebuildmeta into svncommands.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 244
diff changeset
147
247
1272e87546ed Move help, update into svncommands.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 246
diff changeset
148
1272e87546ed Move help, update into svncommands.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 246
diff changeset
149 def help(ui, args=None, **opts):
1272e87546ed Move help, update into svncommands.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 246
diff changeset
150 """show help for a given subcommands or a help overview
1272e87546ed Move help, update into svncommands.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 246
diff changeset
151 """
1272e87546ed Move help, update into svncommands.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 246
diff changeset
152 if args:
1272e87546ed Move help, update into svncommands.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 246
diff changeset
153 subcommand = args[0]
253
c3d5c4ae9c7c Work with simple command table instead of decorators.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 247
diff changeset
154 if subcommand not in table:
247
1272e87546ed Move help, update into svncommands.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 246
diff changeset
155 candidates = []
253
c3d5c4ae9c7c Work with simple command table instead of decorators.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 247
diff changeset
156 for c in table:
247
1272e87546ed Move help, update into svncommands.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 246
diff changeset
157 if c.startswith(subcommand):
1272e87546ed Move help, update into svncommands.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 246
diff changeset
158 candidates.append(c)
1272e87546ed Move help, update into svncommands.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 246
diff changeset
159 if len(candidates) == 1:
1272e87546ed Move help, update into svncommands.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 246
diff changeset
160 subcommand = candidates[0]
1272e87546ed Move help, update into svncommands.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 246
diff changeset
161 elif len(candidates) > 1:
1272e87546ed Move help, update into svncommands.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 246
diff changeset
162 ui.status('Ambiguous command. Could have been:\n%s\n' %
1272e87546ed Move help, update into svncommands.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 246
diff changeset
163 ' '.join(candidates))
1272e87546ed Move help, update into svncommands.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 246
diff changeset
164 return
253
c3d5c4ae9c7c Work with simple command table instead of decorators.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 247
diff changeset
165 doc = table[subcommand].__doc__
247
1272e87546ed Move help, update into svncommands.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 246
diff changeset
166 if doc is None:
1272e87546ed Move help, update into svncommands.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 246
diff changeset
167 doc = "No documentation available for %s." % subcommand
1272e87546ed Move help, update into svncommands.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 246
diff changeset
168 ui.status(doc.strip(), '\n')
1272e87546ed Move help, update into svncommands.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 246
diff changeset
169 return
253
c3d5c4ae9c7c Work with simple command table instead of decorators.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 247
diff changeset
170 ui.status(_helpgen())
247
1272e87546ed Move help, update into svncommands.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 246
diff changeset
171
1272e87546ed Move help, update into svncommands.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 246
diff changeset
172
1272e87546ed Move help, update into svncommands.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 246
diff changeset
173 def update(ui, args, repo, clean=False, **opts):
1272e87546ed Move help, update into svncommands.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 246
diff changeset
174 """update to a specified Subversion revision number
1272e87546ed Move help, update into svncommands.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 246
diff changeset
175 """
1272e87546ed Move help, update into svncommands.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 246
diff changeset
176 assert len(args) == 1
1272e87546ed Move help, update into svncommands.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 246
diff changeset
177 rev = int(args[0])
1272e87546ed Move help, update into svncommands.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 246
diff changeset
178 path = os.path.join(repo.path, 'svn', 'rev_map')
1272e87546ed Move help, update into svncommands.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 246
diff changeset
179 answers = []
1272e87546ed Move help, update into svncommands.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 246
diff changeset
180 for k,v in util.parse_revmap(path).iteritems():
1272e87546ed Move help, update into svncommands.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 246
diff changeset
181 if k[0] == rev:
1272e87546ed Move help, update into svncommands.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 246
diff changeset
182 answers.append((v, k[1]))
1272e87546ed Move help, update into svncommands.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 246
diff changeset
183 if len(answers) == 1:
1272e87546ed Move help, update into svncommands.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 246
diff changeset
184 if clean:
1272e87546ed Move help, update into svncommands.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 246
diff changeset
185 return hg.clean(repo, answers[0][0])
1272e87546ed Move help, update into svncommands.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 246
diff changeset
186 return hg.update(repo, answers[0][0])
1272e87546ed Move help, update into svncommands.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 246
diff changeset
187 elif len(answers) == 0:
1272e87546ed Move help, update into svncommands.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 246
diff changeset
188 ui.status('Revision %s did not produce an hg revision.\n' % rev)
1272e87546ed Move help, update into svncommands.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 246
diff changeset
189 return 1
1272e87546ed Move help, update into svncommands.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 246
diff changeset
190 else:
1272e87546ed Move help, update into svncommands.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 246
diff changeset
191 ui.status('Ambiguous revision!\n')
1272e87546ed Move help, update into svncommands.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 246
diff changeset
192 ui.status('\n'.join(['%s on %s' % (node.hex(a[0]), a[1]) for a in
1272e87546ed Move help, update into svncommands.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 246
diff changeset
193 answers]+['']))
1272e87546ed Move help, update into svncommands.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 246
diff changeset
194 return 1
253
c3d5c4ae9c7c Work with simple command table instead of decorators.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 247
diff changeset
195
c3d5c4ae9c7c Work with simple command table instead of decorators.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 247
diff changeset
196
c3d5c4ae9c7c Work with simple command table instead of decorators.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 247
diff changeset
197 table = {
c3d5c4ae9c7c Work with simple command table instead of decorators.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 247
diff changeset
198 'update': update,
c3d5c4ae9c7c Work with simple command table instead of decorators.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 247
diff changeset
199 'help': help,
c3d5c4ae9c7c Work with simple command table instead of decorators.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 247
diff changeset
200 'rebuildmeta': rebuildmeta,
255
246aaefb1cc0 Add a basic incoming command.
Nat Williams <nat.williams@gmail.com>
parents: 253
diff changeset
201 'incoming': incoming,
291
ba8e91a7c077 Add 'updateexternals' to synchronize externals with remote repo.
Patrick Mezard <pmezard@gmail.com>
parents: 274
diff changeset
202 'updateexternals': svnexternals.updateexternals,
253
c3d5c4ae9c7c Work with simple command table instead of decorators.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 247
diff changeset
203 }
c3d5c4ae9c7c Work with simple command table instead of decorators.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 247
diff changeset
204
c3d5c4ae9c7c Work with simple command table instead of decorators.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 247
diff changeset
205 table.update(utility_commands.table)
c3d5c4ae9c7c Work with simple command table instead of decorators.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 247
diff changeset
206
c3d5c4ae9c7c Work with simple command table instead of decorators.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 247
diff changeset
207
c3d5c4ae9c7c Work with simple command table instead of decorators.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 247
diff changeset
208 def _helpgen():
c3d5c4ae9c7c Work with simple command table instead of decorators.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 247
diff changeset
209 ret = ['hg svn ...', '',
c3d5c4ae9c7c Work with simple command table instead of decorators.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 247
diff changeset
210 'subcommands for Subversion integration', '',
c3d5c4ae9c7c Work with simple command table instead of decorators.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 247
diff changeset
211 'list of subcommands:', '']
c3d5c4ae9c7c Work with simple command table instead of decorators.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 247
diff changeset
212 for name, func in sorted(table.items()):
c3d5c4ae9c7c Work with simple command table instead of decorators.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 247
diff changeset
213 short_description = (func.__doc__ or '').splitlines()[0]
c3d5c4ae9c7c Work with simple command table instead of decorators.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 247
diff changeset
214 ret.append(" %-10s %s" % (name, short_description))
c3d5c4ae9c7c Work with simple command table instead of decorators.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 247
diff changeset
215 return '\n'.join(ret) + '\n'