annotate hgsubversion/svncommands.py @ 1558:ae572c9be4e6

cleanup: remove lots of dead imports and code found by pyflakes
author Augie Fackler <raf@durin42.com>
date Sat, 24 Mar 2018 17:04:19 -0400
parents cff81f35b31e
children 51e105c7f0c6
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
616
532c545d162c svncommands: add two missing imports
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 611
diff changeset
2 import sys
532c545d162c svncommands: add two missing imports
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 611
diff changeset
3 import traceback
989
68191be64af8 updatemeta: fix missing errno import
Patrick Mezard <patrick@mezard.eu>
parents: 988
diff changeset
4 import errno
241
4950b18cf949 Move fetch_command.fetch_revisions() to svncommands.pull().
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff changeset
5
598
e432b61c6d74 Use Mercurial-provided infrastructure for `svn' metacommand help.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 595
diff changeset
6 from mercurial import commands
242
06130689a2c8 Move push into svncommands.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 241
diff changeset
7 from mercurial import hg
06130689a2c8 Move push into svncommands.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 241
diff changeset
8 from mercurial import node
241
4950b18cf949 Move fetch_command.fetch_revisions() to svncommands.pull().
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff changeset
9 from mercurial import util as hgutil
573
00393e9abff8 svncommands: make repo optional (useful for things like listauthors)
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 566
diff changeset
10 from mercurial import error
242
06130689a2c8 Move push into svncommands.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 241
diff changeset
11
241
4950b18cf949 Move fetch_command.fetch_revisions() to svncommands.pull().
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff changeset
12 import svnwrap
464
0f7095f53ca3 Extend svnrepos with SubversionRepo and SVNMeta
Patrick Mezard <pmezard@gmail.com>
parents: 463
diff changeset
13 import svnrepo
241
4950b18cf949 Move fetch_command.fetch_revisions() to svncommands.pull().
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff changeset
14 import util
291
ba8e91a7c077 Add 'updateexternals' to synchronize externals with remote repo.
Patrick Mezard <pmezard@gmail.com>
parents: 274
diff changeset
15 import svnexternals
897
6bc8046e3d0a move verify to a file of its own
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 893
diff changeset
16 import verify
1162
cb14dba562eb svncommands: add svnmeta object
Sean Farley <sean.michael.farley@gmail.com>
parents: 1152
diff changeset
17 import svnmeta
241
4950b18cf949 Move fetch_command.fetch_revisions() to svncommands.pull().
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
diff changeset
18
578
de384e4e0423 merge commands from utility_commands into svncommands
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 573
diff changeset
19
890
78db88de9622 Partial metadata rebuilding
David Schleimer <dschleimer@fb.com>
parents: 885
diff changeset
20 def updatemeta(ui, repo, args, **opts):
78db88de9622 Partial metadata rebuilding
David Schleimer <dschleimer@fb.com>
parents: 885
diff changeset
21 """Do a partial rebuild of the subversion metadata.
78db88de9622 Partial metadata rebuilding
David Schleimer <dschleimer@fb.com>
parents: 885
diff changeset
22
78db88de9622 Partial metadata rebuilding
David Schleimer <dschleimer@fb.com>
parents: 885
diff changeset
23 Assumes that the metadata that currently exists is valid, but that
78db88de9622 Partial metadata rebuilding
David Schleimer <dschleimer@fb.com>
parents: 885
diff changeset
24 some is missing, e.g. because you have pulled some revisions via a
78db88de9622 Partial metadata rebuilding
David Schleimer <dschleimer@fb.com>
parents: 885
diff changeset
25 native mercurial method.
78db88de9622 Partial metadata rebuilding
David Schleimer <dschleimer@fb.com>
parents: 885
diff changeset
26
78db88de9622 Partial metadata rebuilding
David Schleimer <dschleimer@fb.com>
parents: 885
diff changeset
27 """
78db88de9622 Partial metadata rebuilding
David Schleimer <dschleimer@fb.com>
parents: 885
diff changeset
28
78db88de9622 Partial metadata rebuilding
David Schleimer <dschleimer@fb.com>
parents: 885
diff changeset
29 return _buildmeta(ui, repo, args, partial=True)
78db88de9622 Partial metadata rebuilding
David Schleimer <dschleimer@fb.com>
parents: 885
diff changeset
30
395
636e9bf5d49c svncommands: add verify command
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 384
diff changeset
31
918
761a87134501 rebuildmeta: accept unrelated svn repo with --unsafe-skip-uuid-check
Patrick Mezard <patrick@mezard.eu>
parents: 913
diff changeset
32 def rebuildmeta(ui, repo, args, unsafe_skip_uuid_check=False, **opts):
246
074f27c68818 Move rebuildmeta into svncommands.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 244
diff changeset
33 """rebuild hgsubversion metadata using values stored in revisions
074f27c68818 Move rebuildmeta into svncommands.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 244
diff changeset
34 """
918
761a87134501 rebuildmeta: accept unrelated svn repo with --unsafe-skip-uuid-check
Patrick Mezard <patrick@mezard.eu>
parents: 913
diff changeset
35 return _buildmeta(ui, repo, args, partial=False,
761a87134501 rebuildmeta: accept unrelated svn repo with --unsafe-skip-uuid-check
Patrick Mezard <patrick@mezard.eu>
parents: 913
diff changeset
36 skipuuid=unsafe_skip_uuid_check)
573
00393e9abff8 svncommands: make repo optional (useful for things like listauthors)
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 566
diff changeset
37
918
761a87134501 rebuildmeta: accept unrelated svn repo with --unsafe-skip-uuid-check
Patrick Mezard <patrick@mezard.eu>
parents: 913
diff changeset
38 def _buildmeta(ui, repo, args, partial=False, skipuuid=False):
890
78db88de9622 Partial metadata rebuilding
David Schleimer <dschleimer@fb.com>
parents: 885
diff changeset
39
573
00393e9abff8 svncommands: make repo optional (useful for things like listauthors)
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 566
diff changeset
40 if repo is None:
00393e9abff8 svncommands: make repo optional (useful for things like listauthors)
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 566
diff changeset
41 raise error.RepoError("There is no Mercurial repository"
00393e9abff8 svncommands: make repo optional (useful for things like listauthors)
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 566
diff changeset
42 " here (.hg not found)")
00393e9abff8 svncommands: make repo optional (useful for things like listauthors)
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 566
diff changeset
43
453
bb612e625be6 tags: handle copyfrom old versions of tags more correctly
Augie Fackler <durin42@gmail.com>
parents: 452
diff changeset
44 dest = None
1002
117b3b421294 buildmeta: verify uuid when passed explicit url
David Schleimer <dschleimer@fb.com>
parents: 997
diff changeset
45 validateuuid = False
453
bb612e625be6 tags: handle copyfrom old versions of tags more correctly
Augie Fackler <durin42@gmail.com>
parents: 452
diff changeset
46 if len(args) == 1:
419
3ed71e63f64c imported patch import-cleanup
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 414
diff changeset
47 dest = args[0]
1002
117b3b421294 buildmeta: verify uuid when passed explicit url
David Schleimer <dschleimer@fb.com>
parents: 997
diff changeset
48 validateuuid = True
453
bb612e625be6 tags: handle copyfrom old versions of tags more correctly
Augie Fackler <durin42@gmail.com>
parents: 452
diff changeset
49 elif len(args) > 1:
1555
cff81f35b31e cleanup: reference Abort from mercurial.error instead of mercurial.util
Augie Fackler <raf@durin42.com>
parents: 1503
diff changeset
50 raise error.Abort('rebuildmeta takes 1 or no arguments')
754
caa527346a0f svncommands: abort on missing metadata or Subversion URL (fixes #226)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 748
diff changeset
51 url = repo.ui.expandpath(dest or repo.ui.config('paths', 'default-push') or
caa527346a0f svncommands: abort on missing metadata or Subversion URL (fixes #226)
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 748
diff changeset
52 repo.ui.config('paths', 'default') or '')
1162
cb14dba562eb svncommands: add svnmeta object
Sean Farley <sean.michael.farley@gmail.com>
parents: 1152
diff changeset
53
cb14dba562eb svncommands: add svnmeta object
Sean Farley <sean.michael.farley@gmail.com>
parents: 1152
diff changeset
54 meta = svnmeta.SVNMeta(repo, skiperrorcheck=True)
246
074f27c68818 Move rebuildmeta into svncommands.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 244
diff changeset
55
997
c8cb06e1f323 buildmeta: do not contact svn unless needed
Bryan O'Sullivan <bryano@fb.com>
parents: 996
diff changeset
56 svn = None
1165
eba7de99c576 svncommands: use meta.subdir instead of duplicating code
Sean Farley <sean.michael.farley@gmail.com>
parents: 1164
diff changeset
57 if meta.subdir is None:
997
c8cb06e1f323 buildmeta: do not contact svn unless needed
Bryan O'Sullivan <bryano@fb.com>
parents: 996
diff changeset
58 svn = svnrepo.svnremoterepo(ui, url).svn
1165
eba7de99c576 svncommands: use meta.subdir instead of duplicating code
Sean Farley <sean.michael.farley@gmail.com>
parents: 1164
diff changeset
59 meta.subdir = svn.subdir
246
074f27c68818 Move rebuildmeta into svncommands.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 244
diff changeset
60
890
78db88de9622 Partial metadata rebuilding
David Schleimer <dschleimer@fb.com>
parents: 885
diff changeset
61 youngest = 0
78db88de9622 Partial metadata rebuilding
David Schleimer <dschleimer@fb.com>
parents: 885
diff changeset
62 startrev = 0
78db88de9622 Partial metadata rebuilding
David Schleimer <dschleimer@fb.com>
parents: 885
diff changeset
63 branchinfo = {}
1466
16242cec256f svncommands: unlink revmap file before rebuildmeta
Jun Wu <quark@fb.com>
parents: 1461
diff changeset
64
16242cec256f svncommands: unlink revmap file before rebuildmeta
Jun Wu <quark@fb.com>
parents: 1461
diff changeset
65 if not partial:
16242cec256f svncommands: unlink revmap file before rebuildmeta
Jun Wu <quark@fb.com>
parents: 1461
diff changeset
66 hgutil.unlinkpath(meta.revmap_file, ignoremissing=True)
16242cec256f svncommands: unlink revmap file before rebuildmeta
Jun Wu <quark@fb.com>
parents: 1461
diff changeset
67
1420
014c47a8e653 svncommands: get rid of RevMap.readmapfile
Jun Wu <quark@fb.com>
parents: 1377
diff changeset
68 revmap = meta.revmap
890
78db88de9622 Partial metadata rebuilding
David Schleimer <dschleimer@fb.com>
parents: 885
diff changeset
69 if partial:
78db88de9622 Partial metadata rebuilding
David Schleimer <dschleimer@fb.com>
parents: 885
diff changeset
70 try:
1185
65ca78ac2ee1 svncommands: use meta.lastpulled instead of revmap.youngest
Sean Farley <sean.michael.farley@gmail.com>
parents: 1182
diff changeset
71 # we can't use meta.lastpulled here because we are bootstraping the
65ca78ac2ee1 svncommands: use meta.lastpulled instead of revmap.youngest
Sean Farley <sean.michael.farley@gmail.com>
parents: 1182
diff changeset
72 # lastpulled and want to keep the cached value on disk during a
65ca78ac2ee1 svncommands: use meta.lastpulled instead of revmap.youngest
Sean Farley <sean.michael.farley@gmail.com>
parents: 1182
diff changeset
73 # partial rebuild
922
6b7ac659c855 updatemeta: correctly handle empty metadata
Jun Fang <junfang@fb.com>
parents: 918
diff changeset
74 foundpartialinfo = False
1185
65ca78ac2ee1 svncommands: use meta.lastpulled instead of revmap.youngest
Sean Farley <sean.michael.farley@gmail.com>
parents: 1182
diff changeset
75 youngestpath = os.path.join(meta.metapath, 'lastpulled')
922
6b7ac659c855 updatemeta: correctly handle empty metadata
Jun Fang <junfang@fb.com>
parents: 918
diff changeset
76 if os.path.exists(youngestpath):
1142
f4a32d381e03 util: remove all calls to load_string
Sean Farley <sean.michael.farley@gmail.com>
parents: 1132
diff changeset
77 youngest = util.load(youngestpath)
1420
014c47a8e653 svncommands: get rid of RevMap.readmapfile
Jun Wu <quark@fb.com>
parents: 1377
diff changeset
78 lasthash = revmap.lasthash
014c47a8e653 svncommands: get rid of RevMap.readmapfile
Jun Wu <quark@fb.com>
parents: 1377
diff changeset
79 if len(revmap) > 0 and lasthash:
922
6b7ac659c855 updatemeta: correctly handle empty metadata
Jun Fang <junfang@fb.com>
parents: 918
diff changeset
80 startrev = repo[lasthash].rev() + 1
1166
8a1bf7d011c3 svncommands: use meta.branch_info instead of duplicating logic
Sean Farley <sean.michael.farley@gmail.com>
parents: 1165
diff changeset
81 branchinfo = util.load(meta.branch_info_file)
922
6b7ac659c855 updatemeta: correctly handle empty metadata
Jun Fang <junfang@fb.com>
parents: 918
diff changeset
82 foundpartialinfo = True
6b7ac659c855 updatemeta: correctly handle empty metadata
Jun Fang <junfang@fb.com>
parents: 918
diff changeset
83 if not foundpartialinfo:
6b7ac659c855 updatemeta: correctly handle empty metadata
Jun Fang <junfang@fb.com>
parents: 918
diff changeset
84 ui.status('missing some metadata -- doing a full rebuild\n')
6b7ac659c855 updatemeta: correctly handle empty metadata
Jun Fang <junfang@fb.com>
parents: 918
diff changeset
85 partial = False
890
78db88de9622 Partial metadata rebuilding
David Schleimer <dschleimer@fb.com>
parents: 885
diff changeset
86 except IOError, err:
78db88de9622 Partial metadata rebuilding
David Schleimer <dschleimer@fb.com>
parents: 885
diff changeset
87 if err.errno != errno.ENOENT:
78db88de9622 Partial metadata rebuilding
David Schleimer <dschleimer@fb.com>
parents: 885
diff changeset
88 raise
988
06d0009b22ad updatemeta: add missing EOL to status messages
Patrick Mezard <patrick@mezard.eu>
parents: 922
diff changeset
89 ui.status('missing some metadata -- doing a full rebuild\n')
913
9fff2b8217b6 add except for AttributeError if youngestrepo doesn't exist
Brad Hall <bhall@fb.com>
parents: 897
diff changeset
90 except AttributeError:
988
06d0009b22ad updatemeta: add missing EOL to status messages
Patrick Mezard <patrick@mezard.eu>
parents: 922
diff changeset
91 ui.status('no metadata available -- doing a full rebuild\n')
890
78db88de9622 Partial metadata rebuilding
David Schleimer <dschleimer@fb.com>
parents: 885
diff changeset
92
1420
014c47a8e653 svncommands: get rid of RevMap.readmapfile
Jun Wu <quark@fb.com>
parents: 1377
diff changeset
93 if not partial:
014c47a8e653 svncommands: get rid of RevMap.readmapfile
Jun Wu <quark@fb.com>
parents: 1377
diff changeset
94 revmap.clear()
014c47a8e653 svncommands: get rid of RevMap.readmapfile
Jun Wu <quark@fb.com>
parents: 1377
diff changeset
95
246
074f27c68818 Move rebuildmeta into svncommands.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 244
diff changeset
96 last_rev = -1
1167
4f31a0a6fc86 svncommands: use meta.tags instead of duplicating code
Sean Farley <sean.michael.farley@gmail.com>
parents: 1166
diff changeset
97 if not partial and os.path.exists(meta.tagfile):
4f31a0a6fc86 svncommands: use meta.tags instead of duplicating code
Sean Farley <sean.michael.farley@gmail.com>
parents: 1166
diff changeset
98 os.unlink(meta.tagfile)
452
ae35c389cdef tags: allow editing tags of closed branches without reopening the branch
Augie Fackler <durin42@gmail.com>
parents: 448
diff changeset
99
ae35c389cdef tags: allow editing tags of closed branches without reopening the branch
Augie Fackler <durin42@gmail.com>
parents: 448
diff changeset
100 skipped = set()
637
92f4a4b60696 rebuildmeta: optimize by removing quadratic time usage
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 616
diff changeset
101 closed = set()
452
ae35c389cdef tags: allow editing tags of closed branches without reopening the branch
Augie Fackler <durin42@gmail.com>
parents: 448
diff changeset
102
890
78db88de9622 Partial metadata rebuilding
David Schleimer <dschleimer@fb.com>
parents: 885
diff changeset
103 numrevs = len(repo) - startrev
637
92f4a4b60696 rebuildmeta: optimize by removing quadratic time usage
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 616
diff changeset
104
92f4a4b60696 rebuildmeta: optimize by removing quadratic time usage
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 616
diff changeset
105 # ctx.children() visits all revisions in the repository after ctx. Calling
92f4a4b60696 rebuildmeta: optimize by removing quadratic time usage
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 616
diff changeset
106 # it would make us use O(revisions^2) time, so we perform an extra traversal
92f4a4b60696 rebuildmeta: optimize by removing quadratic time usage
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 616
diff changeset
107 # of the repository instead. During this traversal, we find all converted
92f4a4b60696 rebuildmeta: optimize by removing quadratic time usage
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 616
diff changeset
108 # changesets that close a branch, and store their first parent
1461
cbc48ed3b56c rebuildmeta: extract utility function for iterating over repositories
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 1434
diff changeset
109 for ctx in util.get_contexts(repo, startrev):
cbc48ed3b56c rebuildmeta: extract utility function for iterating over repositories
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 1434
diff changeset
110 ui.progress('prepare', ctx.rev() - startrev, total=numrevs)
1019
d0f3a5c2cb56 updatemeta/rebuildmeta: handle hidden changesets
Dan Villiom Podlaski Christiansen <dan@cabo.dk>
parents: 922
diff changeset
111
884
1b261e0f85aa Abstract away the details of where svn revs are stored in a commit
Bryan O'Sullivan <bryano@fb.com>
parents: 881
diff changeset
112 convinfo = util.getsvnrev(ctx, None)
821
f28e0f54a6ef svnmeta: store youngest revision pulled from subversion
Augie Fackler <durin42@gmail.com>
parents: 810
diff changeset
113 if not convinfo:
f28e0f54a6ef svnmeta: store youngest revision pulled from subversion
Augie Fackler <durin42@gmail.com>
parents: 810
diff changeset
114 continue
f28e0f54a6ef svnmeta: store youngest revision pulled from subversion
Augie Fackler <durin42@gmail.com>
parents: 810
diff changeset
115 svnrevnum = int(convinfo.rsplit('@', 1)[1])
f28e0f54a6ef svnmeta: store youngest revision pulled from subversion
Augie Fackler <durin42@gmail.com>
parents: 810
diff changeset
116 youngest = max(youngest, svnrevnum)
637
92f4a4b60696 rebuildmeta: optimize by removing quadratic time usage
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 616
diff changeset
117
884
1b261e0f85aa Abstract away the details of where svn revs are stored in a commit
Bryan O'Sullivan <bryano@fb.com>
parents: 881
diff changeset
118 if ctx.extra().get('close', None) is None:
637
92f4a4b60696 rebuildmeta: optimize by removing quadratic time usage
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 616
diff changeset
119 continue
92f4a4b60696 rebuildmeta: optimize by removing quadratic time usage
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 616
diff changeset
120
92f4a4b60696 rebuildmeta: optimize by removing quadratic time usage
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 616
diff changeset
121 droprev = lambda x: x.rsplit('@', 1)[0]
92f4a4b60696 rebuildmeta: optimize by removing quadratic time usage
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 616
diff changeset
122 parentctx = ctx.parents()[0]
884
1b261e0f85aa Abstract away the details of where svn revs are stored in a commit
Bryan O'Sullivan <bryano@fb.com>
parents: 881
diff changeset
123 parentinfo = util.getsvnrev(parentctx, '@')
637
92f4a4b60696 rebuildmeta: optimize by removing quadratic time usage
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 616
diff changeset
124
92f4a4b60696 rebuildmeta: optimize by removing quadratic time usage
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 616
diff changeset
125 if droprev(parentinfo) == droprev(convinfo):
890
78db88de9622 Partial metadata rebuilding
David Schleimer <dschleimer@fb.com>
parents: 885
diff changeset
126 if parentctx.rev() < startrev:
78db88de9622 Partial metadata rebuilding
David Schleimer <dschleimer@fb.com>
parents: 885
diff changeset
127 parentbranch = parentctx.branch()
78db88de9622 Partial metadata rebuilding
David Schleimer <dschleimer@fb.com>
parents: 885
diff changeset
128 if parentbranch == 'default':
78db88de9622 Partial metadata rebuilding
David Schleimer <dschleimer@fb.com>
parents: 885
diff changeset
129 parentbranch = None
78db88de9622 Partial metadata rebuilding
David Schleimer <dschleimer@fb.com>
parents: 885
diff changeset
130 branchinfo.pop(parentbranch)
78db88de9622 Partial metadata rebuilding
David Schleimer <dschleimer@fb.com>
parents: 885
diff changeset
131 else:
78db88de9622 Partial metadata rebuilding
David Schleimer <dschleimer@fb.com>
parents: 885
diff changeset
132 closed.add(parentctx.rev())
637
92f4a4b60696 rebuildmeta: optimize by removing quadratic time usage
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 616
diff changeset
133
1039
3df6ed4e7561 drop support for pre-2.0 versions of Mercurial
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 1033
diff changeset
134 ui.progress('prepare', None, total=numrevs)
637
92f4a4b60696 rebuildmeta: optimize by removing quadratic time usage
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 616
diff changeset
135
1420
014c47a8e653 svncommands: get rid of RevMap.readmapfile
Jun Wu <quark@fb.com>
parents: 1377
diff changeset
136 revmapbuf = []
1461
cbc48ed3b56c rebuildmeta: extract utility function for iterating over repositories
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 1434
diff changeset
137 for ctx in util.get_contexts(repo, startrev):
cbc48ed3b56c rebuildmeta: extract utility function for iterating over repositories
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 1434
diff changeset
138 ui.progress('rebuild', ctx.rev() - startrev, total=numrevs)
1019
d0f3a5c2cb56 updatemeta/rebuildmeta: handle hidden changesets
Dan Villiom Podlaski Christiansen <dan@cabo.dk>
parents: 922
diff changeset
139
884
1b261e0f85aa Abstract away the details of where svn revs are stored in a commit
Bryan O'Sullivan <bryano@fb.com>
parents: 881
diff changeset
140 convinfo = util.getsvnrev(ctx, None)
371
b45671850969 Add some comments for rebuildmeta, simplify a little.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 342
diff changeset
141 if not convinfo:
b45671850969 Add some comments for rebuildmeta, simplify a little.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 342
diff changeset
142 continue
448
fbc7cf4fd701 tags: reinstate a tag map file in a better way
Augie Fackler <durin42@gmail.com>
parents: 447
diff changeset
143 if '.hgtags' in ctx.files():
fbc7cf4fd701 tags: reinstate a tag map file in a better way
Augie Fackler <durin42@gmail.com>
parents: 447
diff changeset
144 parent = ctx.parents()[0]
fbc7cf4fd701 tags: reinstate a tag map file in a better way
Augie Fackler <durin42@gmail.com>
parents: 447
diff changeset
145 parentdata = ''
fbc7cf4fd701 tags: reinstate a tag map file in a better way
Augie Fackler <durin42@gmail.com>
parents: 447
diff changeset
146 if '.hgtags' in parent:
fbc7cf4fd701 tags: reinstate a tag map file in a better way
Augie Fackler <durin42@gmail.com>
parents: 447
diff changeset
147 parentdata = parent.filectx('.hgtags').data()
fbc7cf4fd701 tags: reinstate a tag map file in a better way
Augie Fackler <durin42@gmail.com>
parents: 447
diff changeset
148 newdata = ctx.filectx('.hgtags').data()
fbc7cf4fd701 tags: reinstate a tag map file in a better way
Augie Fackler <durin42@gmail.com>
parents: 447
diff changeset
149 for newtag in newdata[len(parentdata):-1].split('\n'):
fbc7cf4fd701 tags: reinstate a tag map file in a better way
Augie Fackler <durin42@gmail.com>
parents: 447
diff changeset
150 ha, tag = newtag.split(' ', 1)
884
1b261e0f85aa Abstract away the details of where svn revs are stored in a commit
Bryan O'Sullivan <bryano@fb.com>
parents: 881
diff changeset
151 tagged = util.getsvnrev(repo[ha], None)
453
bb612e625be6 tags: handle copyfrom old versions of tags more correctly
Augie Fackler <durin42@gmail.com>
parents: 452
diff changeset
152 if tagged is None:
bb612e625be6 tags: handle copyfrom old versions of tags more correctly
Augie Fackler <durin42@gmail.com>
parents: 452
diff changeset
153 tagged = -1
bb612e625be6 tags: handle copyfrom old versions of tags more correctly
Augie Fackler <durin42@gmail.com>
parents: 452
diff changeset
154 else:
bb612e625be6 tags: handle copyfrom old versions of tags more correctly
Augie Fackler <durin42@gmail.com>
parents: 452
diff changeset
155 tagged = int(tagged[40:].split('@')[1])
bb612e625be6 tags: handle copyfrom old versions of tags more correctly
Augie Fackler <durin42@gmail.com>
parents: 452
diff changeset
156 # This is max(tagged rev, tagging rev) because if it is a normal
bb612e625be6 tags: handle copyfrom old versions of tags more correctly
Augie Fackler <durin42@gmail.com>
parents: 452
diff changeset
157 # tag, the tagging revision has the right rev number. However, if it
bb612e625be6 tags: handle copyfrom old versions of tags more correctly
Augie Fackler <durin42@gmail.com>
parents: 452
diff changeset
158 # was an edited tag, then the tagged revision has the correct revision
bb612e625be6 tags: handle copyfrom old versions of tags more correctly
Augie Fackler <durin42@gmail.com>
parents: 452
diff changeset
159 # number.
bb612e625be6 tags: handle copyfrom old versions of tags more correctly
Augie Fackler <durin42@gmail.com>
parents: 452
diff changeset
160 tagging = int(convinfo[40:].split('@')[1])
bb612e625be6 tags: handle copyfrom old versions of tags more correctly
Augie Fackler <durin42@gmail.com>
parents: 452
diff changeset
161 tagrev = max(tagged, tagging)
1167
4f31a0a6fc86 svncommands: use meta.tags instead of duplicating code
Sean Farley <sean.michael.farley@gmail.com>
parents: 1166
diff changeset
162 meta.tags[tag] = node.bin(ha), tagrev
371
b45671850969 Add some comments for rebuildmeta, simplify a little.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 342
diff changeset
163
b45671850969 Add some comments for rebuildmeta, simplify a little.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 342
diff changeset
164 # 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
165 assert convinfo.startswith('svn:')
b45671850969 Add some comments for rebuildmeta, simplify a little.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 342
diff changeset
166 revpath, revision = convinfo[40:].split('@')
1165
eba7de99c576 svncommands: use meta.subdir instead of duplicating code
Sean Farley <sean.michael.farley@gmail.com>
parents: 1164
diff changeset
167 # use tmp variable for testing
eba7de99c576 svncommands: use meta.subdir instead of duplicating code
Sean Farley <sean.michael.farley@gmail.com>
parents: 1164
diff changeset
168 subdir = meta.subdir
371
b45671850969 Add some comments for rebuildmeta, simplify a little.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 342
diff changeset
169 if subdir and subdir[0] != '/':
b45671850969 Add some comments for rebuildmeta, simplify a little.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 342
diff changeset
170 subdir = '/' + subdir
b45671850969 Add some comments for rebuildmeta, simplify a little.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 342
diff changeset
171 if subdir and subdir[-1] == '/':
b45671850969 Add some comments for rebuildmeta, simplify a little.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 342
diff changeset
172 subdir = subdir[:-1]
b45671850969 Add some comments for rebuildmeta, simplify a little.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 342
diff changeset
173 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
174 'right location in the repo.')
b45671850969 Add some comments for rebuildmeta, simplify a little.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 342
diff changeset
175
1317
62fc5850eb28 svncommads: document the auto layout block
Sean Farley <sean.michael.farley@gmail.com>
parents: 1313
diff changeset
176 # meta.layout is a config-cached property so instead of testing for
62fc5850eb28 svncommads: document the auto layout block
Sean Farley <sean.michael.farley@gmail.com>
parents: 1313
diff changeset
177 # None we test to see if the layout is 'auto' and, if so, try to guess
62fc5850eb28 svncommads: document the auto layout block
Sean Farley <sean.michael.farley@gmail.com>
parents: 1313
diff changeset
178 # the layout based on the commits (where subdir is compared to the
62fc5850eb28 svncommads: document the auto layout block
Sean Farley <sean.michael.farley@gmail.com>
parents: 1313
diff changeset
179 # revpath extracted from the commit)
1313
5f80c92be718 svncommands: rip out layout logic and use meta object
Sean Farley <sean.michael.farley@gmail.com>
parents: 1292
diff changeset
180 if meta.layout == 'auto':
1317
62fc5850eb28 svncommads: document the auto layout block
Sean Farley <sean.michael.farley@gmail.com>
parents: 1313
diff changeset
181 meta.layout = meta.layout_from_commit(subdir, revpath,
62fc5850eb28 svncommads: document the auto layout block
Sean Farley <sean.michael.farley@gmail.com>
parents: 1313
diff changeset
182 ctx.branch())
1313
5f80c92be718 svncommands: rip out layout logic and use meta object
Sean Farley <sean.michael.farley@gmail.com>
parents: 1292
diff changeset
183 elif meta.layout == 'single':
499
1fd3cfa47c5e Support for single-directory clones.
Augie Fackler <durin42@gmail.com>
parents: 493
diff changeset
184 assert (subdir or '/') == revpath, ('Possible layout detection'
1fd3cfa47c5e Support for single-directory clones.
Augie Fackler <durin42@gmail.com>
parents: 493
diff changeset
185 ' defect in replay')
1fd3cfa47c5e Support for single-directory clones.
Augie Fackler <durin42@gmail.com>
parents: 493
diff changeset
186
371
b45671850969 Add some comments for rebuildmeta, simplify a little.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 342
diff changeset
187 # write repository uuid if required
1164
52de1f3b6824 svncommands: use meta.uuid instead of duplicating code
Sean Farley <sean.michael.farley@gmail.com>
parents: 1163
diff changeset
188 if meta.uuid is None or validateuuid:
1002
117b3b421294 buildmeta: verify uuid when passed explicit url
David Schleimer <dschleimer@fb.com>
parents: 997
diff changeset
189 validateuuid = False
371
b45671850969 Add some comments for rebuildmeta, simplify a little.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 342
diff changeset
190 uuid = convinfo[4:40]
918
761a87134501 rebuildmeta: accept unrelated svn repo with --unsafe-skip-uuid-check
Patrick Mezard <patrick@mezard.eu>
parents: 913
diff changeset
191 if not skipuuid:
997
c8cb06e1f323 buildmeta: do not contact svn unless needed
Bryan O'Sullivan <bryano@fb.com>
parents: 996
diff changeset
192 if svn is None:
c8cb06e1f323 buildmeta: do not contact svn unless needed
Bryan O'Sullivan <bryano@fb.com>
parents: 996
diff changeset
193 svn = svnrepo.svnremoterepo(ui, url).svn
918
761a87134501 rebuildmeta: accept unrelated svn repo with --unsafe-skip-uuid-check
Patrick Mezard <patrick@mezard.eu>
parents: 913
diff changeset
194 if uuid != svn.uuid:
1555
cff81f35b31e cleanup: reference Abort from mercurial.error instead of mercurial.util
Augie Fackler <raf@durin42.com>
parents: 1503
diff changeset
195 raise error.Abort('remote svn repository identifier '
918
761a87134501 rebuildmeta: accept unrelated svn repo with --unsafe-skip-uuid-check
Patrick Mezard <patrick@mezard.eu>
parents: 913
diff changeset
196 'does not match')
1164
52de1f3b6824 svncommands: use meta.uuid instead of duplicating code
Sean Farley <sean.michael.farley@gmail.com>
parents: 1163
diff changeset
197 meta.uuid = uuid
371
b45671850969 Add some comments for rebuildmeta, simplify a little.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 342
diff changeset
198
423
021bdbf391bb put convert_revision in branch-closing csets
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 419
diff changeset
199 # don't reflect closed branches
452
ae35c389cdef tags: allow editing tags of closed branches without reopening the branch
Augie Fackler <durin42@gmail.com>
parents: 448
diff changeset
200 if (ctx.extra().get('close') and not ctx.files() or
ae35c389cdef tags: allow editing tags of closed branches without reopening the branch
Augie Fackler <durin42@gmail.com>
parents: 448
diff changeset
201 ctx.parents()[0].node() in skipped):
ae35c389cdef tags: allow editing tags of closed branches without reopening the branch
Augie Fackler <durin42@gmail.com>
parents: 448
diff changeset
202 skipped.add(ctx.node())
423
021bdbf391bb put convert_revision in branch-closing csets
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 419
diff changeset
203 continue
021bdbf391bb put convert_revision in branch-closing csets
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 419
diff changeset
204
371
b45671850969 Add some comments for rebuildmeta, simplify a little.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 342
diff changeset
205 # find commitpath, write to revmap
b45671850969 Add some comments for rebuildmeta, simplify a little.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 342
diff changeset
206 commitpath = revpath[len(subdir)+1:]
1033
32f6b970c762 buildmeta: use layouts library for branch and tag mapping in _buildmeta
David Schleimer <dschleimer@fb.com>
parents: 1021
diff changeset
207
1313
5f80c92be718 svncommands: rip out layout logic and use meta object
Sean Farley <sean.michael.farley@gmail.com>
parents: 1292
diff changeset
208 tag_locations = meta.layoutobj.taglocations
1033
32f6b970c762 buildmeta: use layouts library for branch and tag mapping in _buildmeta
David Schleimer <dschleimer@fb.com>
parents: 1021
diff changeset
209 found_tag = False
32f6b970c762 buildmeta: use layouts library for branch and tag mapping in _buildmeta
David Schleimer <dschleimer@fb.com>
parents: 1021
diff changeset
210 for location in tag_locations:
32f6b970c762 buildmeta: use layouts library for branch and tag mapping in _buildmeta
David Schleimer <dschleimer@fb.com>
parents: 1021
diff changeset
211 if commitpath.startswith(location + '/'):
32f6b970c762 buildmeta: use layouts library for branch and tag mapping in _buildmeta
David Schleimer <dschleimer@fb.com>
parents: 1021
diff changeset
212 found_tag = True
32f6b970c762 buildmeta: use layouts library for branch and tag mapping in _buildmeta
David Schleimer <dschleimer@fb.com>
parents: 1021
diff changeset
213 break
32f6b970c762 buildmeta: use layouts library for branch and tag mapping in _buildmeta
David Schleimer <dschleimer@fb.com>
parents: 1021
diff changeset
214 if found_tag and ctx.extra().get('close'):
32f6b970c762 buildmeta: use layouts library for branch and tag mapping in _buildmeta
David Schleimer <dschleimer@fb.com>
parents: 1021
diff changeset
215 continue
32f6b970c762 buildmeta: use layouts library for branch and tag mapping in _buildmeta
David Schleimer <dschleimer@fb.com>
parents: 1021
diff changeset
216
1313
5f80c92be718 svncommands: rip out layout logic and use meta object
Sean Farley <sean.michael.farley@gmail.com>
parents: 1292
diff changeset
217 branch = meta.layoutobj.localname(commitpath)
1420
014c47a8e653 svncommands: get rid of RevMap.readmapfile
Jun Wu <quark@fb.com>
parents: 1377
diff changeset
218 revmapbuf.append((revision, branch, ctx.node()))
371
b45671850969 Add some comments for rebuildmeta, simplify a little.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 342
diff changeset
219
b45671850969 Add some comments for rebuildmeta, simplify a little.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 342
diff changeset
220 revision = int(revision)
b45671850969 Add some comments for rebuildmeta, simplify a little.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 342
diff changeset
221 if revision > last_rev:
b45671850969 Add some comments for rebuildmeta, simplify a little.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 342
diff changeset
222 last_rev = revision
375
af9fc01299b4 Make branch closing more Mercurial-like.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 371
diff changeset
223
af9fc01299b4 Make branch closing more Mercurial-like.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 371
diff changeset
224 # deal with branches
1033
32f6b970c762 buildmeta: use layouts library for branch and tag mapping in _buildmeta
David Schleimer <dschleimer@fb.com>
parents: 1021
diff changeset
225 if branch and branch.startswith('../'):
641
67513cca972f rebuildmeta: handle mapped branch names.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 637
diff changeset
226 parent = ctx
67513cca972f rebuildmeta: handle mapped branch names.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 637
diff changeset
227 while parent.node() != node.nullid:
67513cca972f rebuildmeta: handle mapped branch names.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 637
diff changeset
228 parentextra = parent.extra()
884
1b261e0f85aa Abstract away the details of where svn revs are stored in a commit
Bryan O'Sullivan <bryano@fb.com>
parents: 881
diff changeset
229 parentinfo = util.getsvnrev(parent)
641
67513cca972f rebuildmeta: handle mapped branch names.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 637
diff changeset
230 assert parentinfo
67513cca972f rebuildmeta: handle mapped branch names.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 637
diff changeset
231 parent = parent.parents()[0]
67513cca972f rebuildmeta: handle mapped branch names.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 637
diff changeset
232
67513cca972f rebuildmeta: handle mapped branch names.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 637
diff changeset
233 parentpath = parentinfo[40:].split('@')[0][len(subdir) + 1:]
67513cca972f rebuildmeta: handle mapped branch names.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 637
diff changeset
234
1033
32f6b970c762 buildmeta: use layouts library for branch and tag mapping in _buildmeta
David Schleimer <dschleimer@fb.com>
parents: 1021
diff changeset
235 found_tag = False
32f6b970c762 buildmeta: use layouts library for branch and tag mapping in _buildmeta
David Schleimer <dschleimer@fb.com>
parents: 1021
diff changeset
236 for location in tag_locations:
32f6b970c762 buildmeta: use layouts library for branch and tag mapping in _buildmeta
David Schleimer <dschleimer@fb.com>
parents: 1021
diff changeset
237 if parentpath.startswith(location + '/'):
32f6b970c762 buildmeta: use layouts library for branch and tag mapping in _buildmeta
David Schleimer <dschleimer@fb.com>
parents: 1021
diff changeset
238 found_tag = True
32f6b970c762 buildmeta: use layouts library for branch and tag mapping in _buildmeta
David Schleimer <dschleimer@fb.com>
parents: 1021
diff changeset
239 break
32f6b970c762 buildmeta: use layouts library for branch and tag mapping in _buildmeta
David Schleimer <dschleimer@fb.com>
parents: 1021
diff changeset
240 if found_tag and parentextra.get('close'):
641
67513cca972f rebuildmeta: handle mapped branch names.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 637
diff changeset
241 continue
1033
32f6b970c762 buildmeta: use layouts library for branch and tag mapping in _buildmeta
David Schleimer <dschleimer@fb.com>
parents: 1021
diff changeset
242
1313
5f80c92be718 svncommands: rip out layout logic and use meta object
Sean Farley <sean.michael.farley@gmail.com>
parents: 1292
diff changeset
243 branch = meta.layoutobj.localname(parentpath)
641
67513cca972f rebuildmeta: handle mapped branch names.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 637
diff changeset
244 break
637
92f4a4b60696 rebuildmeta: optimize by removing quadratic time usage
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 616
diff changeset
245
1461
cbc48ed3b56c rebuildmeta: extract utility function for iterating over repositories
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 1434
diff changeset
246 if ctx.rev() in closed:
637
92f4a4b60696 rebuildmeta: optimize by removing quadratic time usage
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 616
diff changeset
247 # a direct child of this changeset closes the branch; drop it
92f4a4b60696 rebuildmeta: optimize by removing quadratic time usage
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 616
diff changeset
248 branchinfo.pop(branch, None)
641
67513cca972f rebuildmeta: handle mapped branch names.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 637
diff changeset
249 elif ctx.extra().get('close'):
67513cca972f rebuildmeta: handle mapped branch names.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 637
diff changeset
250 pass
637
92f4a4b60696 rebuildmeta: optimize by removing quadratic time usage
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 616
diff changeset
251 elif branch not in branchinfo:
371
b45671850969 Add some comments for rebuildmeta, simplify a little.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 342
diff changeset
252 parent = ctx.parents()[0]
890
78db88de9622 Partial metadata rebuilding
David Schleimer <dschleimer@fb.com>
parents: 885
diff changeset
253 if (parent.node() not in skipped
78db88de9622 Partial metadata rebuilding
David Schleimer <dschleimer@fb.com>
parents: 885
diff changeset
254 and util.getsvnrev(parent, '').startswith('svn:')
371
b45671850969 Add some comments for rebuildmeta, simplify a little.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 342
diff changeset
255 and parent.branch() != ctx.branch()):
b45671850969 Add some comments for rebuildmeta, simplify a little.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 342
diff changeset
256 parentbranch = parent.branch()
b45671850969 Add some comments for rebuildmeta, simplify a little.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 342
diff changeset
257 if parentbranch == 'default':
246
074f27c68818 Move rebuildmeta into svncommands.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 244
diff changeset
258 parentbranch = None
371
b45671850969 Add some comments for rebuildmeta, simplify a little.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 342
diff changeset
259 else:
b45671850969 Add some comments for rebuildmeta, simplify a little.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 342
diff changeset
260 parentbranch = None
890
78db88de9622 Partial metadata rebuilding
David Schleimer <dschleimer@fb.com>
parents: 885
diff changeset
261 # branchinfo is a map from mercurial branch to a
78db88de9622 Partial metadata rebuilding
David Schleimer <dschleimer@fb.com>
parents: 885
diff changeset
262 # (svn branch, svn parent revision, svn revision) tuple
78db88de9622 Partial metadata rebuilding
David Schleimer <dschleimer@fb.com>
parents: 885
diff changeset
263 parentrev = util.getsvnrev(parent, '@').split('@')[1] or 0
371
b45671850969 Add some comments for rebuildmeta, simplify a little.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 342
diff changeset
264 branchinfo[branch] = (parentbranch,
890
78db88de9622 Partial metadata rebuilding
David Schleimer <dschleimer@fb.com>
parents: 885
diff changeset
265 int(parentrev),
371
b45671850969 Add some comments for rebuildmeta, simplify a little.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 342
diff changeset
266 revision)
637
92f4a4b60696 rebuildmeta: optimize by removing quadratic time usage
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 616
diff changeset
267
1434
0a6b3da6d34c RevMap: move lastpulled from SVNMeta down into RevMap
Augie Fackler <raf@durin42.com>
parents: 1420
diff changeset
268 revmap.batchset(revmapbuf, youngest)
1039
3df6ed4e7561 drop support for pre-2.0 versions of Mercurial
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 1033
diff changeset
269 ui.progress('rebuild', None, total=numrevs)
371
b45671850969 Add some comments for rebuildmeta, simplify a little.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 342
diff changeset
270
b45671850969 Add some comments for rebuildmeta, simplify a little.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 342
diff changeset
271 # save off branch info
1166
8a1bf7d011c3 svncommands: use meta.branch_info instead of duplicating logic
Sean Farley <sean.michael.farley@gmail.com>
parents: 1165
diff changeset
272 util.dump(branchinfo, meta.branch_info_file)
246
074f27c68818 Move rebuildmeta into svncommands.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 244
diff changeset
273
247
1272e87546ed Move help, update into svncommands.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 246
diff changeset
274
595
200770235bf0 svncommands: rename the `help' function to `help_'.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 580
diff changeset
275 def help_(ui, args=None, **opts):
247
1272e87546ed Move help, update into svncommands.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 246
diff changeset
276 """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
277 """
1272e87546ed Move help, update into svncommands.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 246
diff changeset
278 if args:
1272e87546ed Move help, update into svncommands.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 246
diff changeset
279 subcommand = args[0]
253
c3d5c4ae9c7c Work with simple command table instead of decorators.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 247
diff changeset
280 if subcommand not in table:
247
1272e87546ed Move help, update into svncommands.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 246
diff changeset
281 candidates = []
253
c3d5c4ae9c7c Work with simple command table instead of decorators.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 247
diff changeset
282 for c in table:
247
1272e87546ed Move help, update into svncommands.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 246
diff changeset
283 if c.startswith(subcommand):
1272e87546ed Move help, update into svncommands.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 246
diff changeset
284 candidates.append(c)
1272e87546ed Move help, update into svncommands.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 246
diff changeset
285 if len(candidates) == 1:
1272e87546ed Move help, update into svncommands.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 246
diff changeset
286 subcommand = candidates[0]
1272e87546ed Move help, update into svncommands.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 246
diff changeset
287 elif len(candidates) > 1:
603
24c73f35f3cf metacommand: use AmbiguousCommand from hg for consistency.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 599
diff changeset
288 raise error.AmbiguousCommand(subcommand, candidates)
247
1272e87546ed Move help, update into svncommands.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 246
diff changeset
289 return
253
c3d5c4ae9c7c Work with simple command table instead of decorators.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 247
diff changeset
290 doc = table[subcommand].__doc__
247
1272e87546ed Move help, update into svncommands.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 246
diff changeset
291 if doc is None:
1272e87546ed Move help, update into svncommands.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 246
diff changeset
292 doc = "No documentation available for %s." % subcommand
1272e87546ed Move help, update into svncommands.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 246
diff changeset
293 ui.status(doc.strip(), '\n')
1272e87546ed Move help, update into svncommands.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 246
diff changeset
294 return
598
e432b61c6d74 Use Mercurial-provided infrastructure for `svn' metacommand help.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 595
diff changeset
295 commands.help_(ui, 'svn')
247
1272e87546ed Move help, update into svncommands.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 246
diff changeset
296
1272e87546ed Move help, update into svncommands.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 246
diff changeset
297
1272e87546ed Move help, update into svncommands.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 246
diff changeset
298 def update(ui, args, repo, clean=False, **opts):
1272e87546ed Move help, update into svncommands.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 246
diff changeset
299 """update to a specified Subversion revision number
1272e87546ed Move help, update into svncommands.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 246
diff changeset
300 """
446
cbd230043379 svncommands: get update working again
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 441
diff changeset
301
755
9c9565643704 svn metacommand: improved argument checking
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 754
diff changeset
302 try:
9c9565643704 svn metacommand: improved argument checking
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 754
diff changeset
303 rev = int(args[0])
9c9565643704 svn metacommand: improved argument checking
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 754
diff changeset
304 except IndexError:
9c9565643704 svn metacommand: improved argument checking
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 754
diff changeset
305 raise error.CommandError('svn',
9c9565643704 svn metacommand: improved argument checking
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 754
diff changeset
306 "no revision number specified for 'update'")
9c9565643704 svn metacommand: improved argument checking
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 754
diff changeset
307 except ValueError:
9c9565643704 svn metacommand: improved argument checking
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 754
diff changeset
308 raise error.Abort("'%s' is not a valid Subversion revision number"
9c9565643704 svn metacommand: improved argument checking
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 754
diff changeset
309 % args[0])
9c9565643704 svn metacommand: improved argument checking
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 754
diff changeset
310
464
0f7095f53ca3 Extend svnrepos with SubversionRepo and SVNMeta
Patrick Mezard <pmezard@gmail.com>
parents: 463
diff changeset
311 meta = repo.svnmeta()
446
cbd230043379 svncommands: get update working again
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 441
diff changeset
312
247
1272e87546ed Move help, update into svncommands.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 246
diff changeset
313 answers = []
446
cbd230043379 svncommands: get update working again
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 441
diff changeset
314 for k, v in meta.revmap.iteritems():
247
1272e87546ed Move help, update into svncommands.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 246
diff changeset
315 if k[0] == rev:
1272e87546ed Move help, update into svncommands.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 246
diff changeset
316 answers.append((v, k[1]))
446
cbd230043379 svncommands: get update working again
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 441
diff changeset
317
247
1272e87546ed Move help, update into svncommands.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 246
diff changeset
318 if len(answers) == 1:
1272e87546ed Move help, update into svncommands.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 246
diff changeset
319 if clean:
1272e87546ed Move help, update into svncommands.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 246
diff changeset
320 return hg.clean(repo, answers[0][0])
1272e87546ed Move help, update into svncommands.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 246
diff changeset
321 return hg.update(repo, answers[0][0])
1272e87546ed Move help, update into svncommands.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 246
diff changeset
322 elif len(answers) == 0:
446
cbd230043379 svncommands: get update working again
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 441
diff changeset
323 ui.status('revision %s did not produce an hg revision\n' % rev)
247
1272e87546ed Move help, update into svncommands.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 246
diff changeset
324 return 1
1272e87546ed Move help, update into svncommands.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 246
diff changeset
325 else:
446
cbd230043379 svncommands: get update working again
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 441
diff changeset
326 ui.status('ambiguous revision!\n')
cbd230043379 svncommands: get update working again
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 441
diff changeset
327 revs = ['%s on %s' % (node.hex(a[0]), a[1]) for a in answers] + ['']
cbd230043379 svncommands: get update working again
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 441
diff changeset
328 ui.status('\n'.join(revs))
247
1272e87546ed Move help, update into svncommands.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 246
diff changeset
329 return 1
253
c3d5c4ae9c7c Work with simple command table instead of decorators.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 247
diff changeset
330
c3d5c4ae9c7c Work with simple command table instead of decorators.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 247
diff changeset
331
578
de384e4e0423 merge commands from utility_commands into svncommands
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 573
diff changeset
332 def genignore(ui, repo, force=False, **opts):
de384e4e0423 merge commands from utility_commands into svncommands
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 573
diff changeset
333 """generate .hgignore from svn:ignore properties.
de384e4e0423 merge commands from utility_commands into svncommands
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 573
diff changeset
334 """
253
c3d5c4ae9c7c Work with simple command table instead of decorators.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 247
diff changeset
335
578
de384e4e0423 merge commands from utility_commands into svncommands
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 573
diff changeset
336 if repo is None:
de384e4e0423 merge commands from utility_commands into svncommands
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 573
diff changeset
337 raise error.RepoError("There is no Mercurial repository"
de384e4e0423 merge commands from utility_commands into svncommands
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 573
diff changeset
338 " here (.hg not found)")
de384e4e0423 merge commands from utility_commands into svncommands
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 573
diff changeset
339
1503
180e0d5fba2e join: remove uses of repo.join/wjoin
Durham Goode <durham@fb.com>
parents: 1466
diff changeset
340 ignpath = repo.wvfs.join('.hgignore')
578
de384e4e0423 merge commands from utility_commands into svncommands
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 573
diff changeset
341 if not force and os.path.exists(ignpath):
1555
cff81f35b31e cleanup: reference Abort from mercurial.error instead of mercurial.util
Augie Fackler <raf@durin42.com>
parents: 1503
diff changeset
342 raise error.Abort('not overwriting existing .hgignore, try --force?')
578
de384e4e0423 merge commands from utility_commands into svncommands
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 573
diff changeset
343 svn = svnrepo.svnremoterepo(repo.ui).svn
de384e4e0423 merge commands from utility_commands into svncommands
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 573
diff changeset
344 meta = repo.svnmeta()
de384e4e0423 merge commands from utility_commands into svncommands
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 573
diff changeset
345 hashes = meta.revmap.hashes()
de384e4e0423 merge commands from utility_commands into svncommands
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 573
diff changeset
346 parent = util.parentrev(ui, repo, meta, hashes)
de384e4e0423 merge commands from utility_commands into svncommands
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 573
diff changeset
347 r, br = hashes[parent.node()]
1015
ea6109f5c000 layouts: use layouts library for branch mapping with generating .hgignore
David Schleimer <dschleimer@fb.com>
parents: 1007
diff changeset
348 branchpath = meta.layoutobj.remotename(br)
ea6109f5c000 layouts: use layouts library for branch mapping with generating .hgignore
David Schleimer <dschleimer@fb.com>
parents: 1007
diff changeset
349 if branchpath:
ea6109f5c000 layouts: use layouts library for branch mapping with generating .hgignore
David Schleimer <dschleimer@fb.com>
parents: 1007
diff changeset
350 branchpath += '/'
578
de384e4e0423 merge commands from utility_commands into svncommands
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 573
diff changeset
351 ignorelines = ['.hgignore', 'syntax:glob']
de384e4e0423 merge commands from utility_commands into svncommands
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 573
diff changeset
352 dirs = [''] + [d[0] for d in svn.list_files(branchpath, r)
de384e4e0423 merge commands from utility_commands into svncommands
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 573
diff changeset
353 if d[1] == 'd']
de384e4e0423 merge commands from utility_commands into svncommands
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 573
diff changeset
354 for dir in dirs:
de384e4e0423 merge commands from utility_commands into svncommands
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 573
diff changeset
355 path = '%s%s' % (branchpath, dir)
de384e4e0423 merge commands from utility_commands into svncommands
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 573
diff changeset
356 props = svn.list_props(path, r)
de384e4e0423 merge commands from utility_commands into svncommands
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 573
diff changeset
357 if 'svn:ignore' not in props:
de384e4e0423 merge commands from utility_commands into svncommands
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 573
diff changeset
358 continue
de384e4e0423 merge commands from utility_commands into svncommands
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 573
diff changeset
359 lines = props['svn:ignore'].strip().split('\n')
1258
85fe080461c6 genignore: fitler out empty lines in svn:ignore.
peter.geer
parents: 1185
diff changeset
360 ignorelines += [dir and (dir + '/' + prop) or prop for prop in lines if prop.strip()]
578
de384e4e0423 merge commands from utility_commands into svncommands
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 573
diff changeset
361
1503
180e0d5fba2e join: remove uses of repo.join/wjoin
Durham Goode <durham@fb.com>
parents: 1466
diff changeset
362 repo.wvfs('.hgignore', 'w').write('\n'.join(ignorelines) + '\n')
578
de384e4e0423 merge commands from utility_commands into svncommands
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 573
diff changeset
363
de384e4e0423 merge commands from utility_commands into svncommands
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 573
diff changeset
364
de384e4e0423 merge commands from utility_commands into svncommands
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 573
diff changeset
365 def info(ui, repo, **opts):
de384e4e0423 merge commands from utility_commands into svncommands
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 573
diff changeset
366 """show Subversion details similar to `svn info'
de384e4e0423 merge commands from utility_commands into svncommands
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 573
diff changeset
367 """
de384e4e0423 merge commands from utility_commands into svncommands
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 573
diff changeset
368
de384e4e0423 merge commands from utility_commands into svncommands
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 573
diff changeset
369 if repo is None:
de384e4e0423 merge commands from utility_commands into svncommands
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 573
diff changeset
370 raise error.RepoError("There is no Mercurial repository"
de384e4e0423 merge commands from utility_commands into svncommands
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 573
diff changeset
371 " here (.hg not found)")
de384e4e0423 merge commands from utility_commands into svncommands
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 573
diff changeset
372
de384e4e0423 merge commands from utility_commands into svncommands
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 573
diff changeset
373 meta = repo.svnmeta()
de384e4e0423 merge commands from utility_commands into svncommands
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 573
diff changeset
374 hashes = meta.revmap.hashes()
de384e4e0423 merge commands from utility_commands into svncommands
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 573
diff changeset
375
de384e4e0423 merge commands from utility_commands into svncommands
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 573
diff changeset
376 if opts.get('rev'):
de384e4e0423 merge commands from utility_commands into svncommands
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 573
diff changeset
377 parent = repo[opts['rev']]
de384e4e0423 merge commands from utility_commands into svncommands
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 573
diff changeset
378 else:
de384e4e0423 merge commands from utility_commands into svncommands
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 573
diff changeset
379 parent = util.parentrev(ui, repo, meta, hashes)
de384e4e0423 merge commands from utility_commands into svncommands
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 573
diff changeset
380
de384e4e0423 merge commands from utility_commands into svncommands
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 573
diff changeset
381 pn = parent.node()
de384e4e0423 merge commands from utility_commands into svncommands
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 573
diff changeset
382 if pn not in hashes:
de384e4e0423 merge commands from utility_commands into svncommands
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 573
diff changeset
383 ui.status('Not a child of an svn revision.\n')
de384e4e0423 merge commands from utility_commands into svncommands
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 573
diff changeset
384 return 0
de384e4e0423 merge commands from utility_commands into svncommands
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 573
diff changeset
385 r, br = hashes[pn]
884
1b261e0f85aa Abstract away the details of where svn revs are stored in a commit
Bryan O'Sullivan <bryano@fb.com>
parents: 881
diff changeset
386 subdir = util.getsvnrev(parent)[40:].split('@')[0]
578
de384e4e0423 merge commands from utility_commands into svncommands
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 573
diff changeset
387 remoterepo = svnrepo.svnremoterepo(repo.ui)
1016
438dc704b0d6 layouts: use layout library in hg svn info
David Schleimer <dschleimer@fb.com>
parents: 1015
diff changeset
388 url = meta.layoutobj.remotepath(br, remoterepo.svnurl)
578
de384e4e0423 merge commands from utility_commands into svncommands
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 573
diff changeset
389 author = meta.authors.reverselookup(parent.user())
de384e4e0423 merge commands from utility_commands into svncommands
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 573
diff changeset
390 # cleverly figure out repo root w/o actually contacting the server
de384e4e0423 merge commands from utility_commands into svncommands
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 573
diff changeset
391 reporoot = url[:len(url)-len(subdir)]
de384e4e0423 merge commands from utility_commands into svncommands
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 573
diff changeset
392 ui.write('''URL: %(url)s
de384e4e0423 merge commands from utility_commands into svncommands
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 573
diff changeset
393 Repository Root: %(reporoot)s
de384e4e0423 merge commands from utility_commands into svncommands
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 573
diff changeset
394 Repository UUID: %(uuid)s
de384e4e0423 merge commands from utility_commands into svncommands
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 573
diff changeset
395 Revision: %(revision)s
de384e4e0423 merge commands from utility_commands into svncommands
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 573
diff changeset
396 Node Kind: directory
de384e4e0423 merge commands from utility_commands into svncommands
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 573
diff changeset
397 Last Changed Author: %(author)s
de384e4e0423 merge commands from utility_commands into svncommands
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 573
diff changeset
398 Last Changed Rev: %(revision)s
de384e4e0423 merge commands from utility_commands into svncommands
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 573
diff changeset
399 Last Changed Date: %(date)s\n''' %
de384e4e0423 merge commands from utility_commands into svncommands
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 573
diff changeset
400 {'reporoot': reporoot,
de384e4e0423 merge commands from utility_commands into svncommands
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 573
diff changeset
401 'uuid': meta.uuid,
de384e4e0423 merge commands from utility_commands into svncommands
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 573
diff changeset
402 'url': url,
de384e4e0423 merge commands from utility_commands into svncommands
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 573
diff changeset
403 'author': author,
de384e4e0423 merge commands from utility_commands into svncommands
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 573
diff changeset
404 'revision': r,
de384e4e0423 merge commands from utility_commands into svncommands
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 573
diff changeset
405 # TODO I'd like to format this to the user's local TZ if possible
de384e4e0423 merge commands from utility_commands into svncommands
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 573
diff changeset
406 'date': hgutil.datestr(parent.date(),
de384e4e0423 merge commands from utility_commands into svncommands
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 573
diff changeset
407 '%Y-%m-%d %H:%M:%S %1%2 (%a, %d %b %Y)')
de384e4e0423 merge commands from utility_commands into svncommands
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 573
diff changeset
408 })
de384e4e0423 merge commands from utility_commands into svncommands
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 573
diff changeset
409
de384e4e0423 merge commands from utility_commands into svncommands
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 573
diff changeset
410
de384e4e0423 merge commands from utility_commands into svncommands
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 573
diff changeset
411 def listauthors(ui, args, authors=None, **opts):
de384e4e0423 merge commands from utility_commands into svncommands
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 573
diff changeset
412 """list all authors in a Subversion repository
de384e4e0423 merge commands from utility_commands into svncommands
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 573
diff changeset
413 """
de384e4e0423 merge commands from utility_commands into svncommands
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 573
diff changeset
414 if not len(args):
de384e4e0423 merge commands from utility_commands into svncommands
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 573
diff changeset
415 ui.status('No repository specified.\n')
de384e4e0423 merge commands from utility_commands into svncommands
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 573
diff changeset
416 return
de384e4e0423 merge commands from utility_commands into svncommands
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 573
diff changeset
417 svn = svnrepo.svnremoterepo(ui, args[0]).svn
de384e4e0423 merge commands from utility_commands into svncommands
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 573
diff changeset
418 author_set = set()
de384e4e0423 merge commands from utility_commands into svncommands
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 573
diff changeset
419 for rev in svn.revisions():
735
c2b9e08ecf10 maps: map a missing author to '(no author)'
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 728
diff changeset
420 if rev.author is None:
c2b9e08ecf10 maps: map a missing author to '(no author)'
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 728
diff changeset
421 author_set.add('(no author)')
c2b9e08ecf10 maps: map a missing author to '(no author)'
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 728
diff changeset
422 else:
c2b9e08ecf10 maps: map a missing author to '(no author)'
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 728
diff changeset
423 author_set.add(rev.author)
578
de384e4e0423 merge commands from utility_commands into svncommands
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 573
diff changeset
424 if authors:
de384e4e0423 merge commands from utility_commands into svncommands
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 573
diff changeset
425 authorfile = open(authors, 'w')
de384e4e0423 merge commands from utility_commands into svncommands
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 573
diff changeset
426 authorfile.write('%s=\n' % '=\n'.join(sorted(author_set)))
de384e4e0423 merge commands from utility_commands into svncommands
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 573
diff changeset
427 authorfile.close()
de384e4e0423 merge commands from utility_commands into svncommands
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 573
diff changeset
428 else:
de384e4e0423 merge commands from utility_commands into svncommands
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 573
diff changeset
429 ui.write('%s\n' % '\n'.join(sorted(author_set)))
253
c3d5c4ae9c7c Work with simple command table instead of decorators.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 247
diff changeset
430
c3d5c4ae9c7c Work with simple command table instead of decorators.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 247
diff changeset
431
c3d5c4ae9c7c Work with simple command table instead of decorators.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 247
diff changeset
432 def _helpgen():
598
e432b61c6d74 Use Mercurial-provided infrastructure for `svn' metacommand help.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 595
diff changeset
433 ret = ['subcommands for Subversion integration', '',
253
c3d5c4ae9c7c Work with simple command table instead of decorators.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 247
diff changeset
434 'list of subcommands:', '']
c3d5c4ae9c7c Work with simple command table instead of decorators.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 247
diff changeset
435 for name, func in sorted(table.items()):
504
bc117ea4c95a do not assume that doc-strings are present.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 499
diff changeset
436 if func.__doc__:
bc117ea4c95a do not assume that doc-strings are present.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 499
diff changeset
437 short_description = func.__doc__.splitlines()[0]
bc117ea4c95a do not assume that doc-strings are present.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 499
diff changeset
438 else:
bc117ea4c95a do not assume that doc-strings are present.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 499
diff changeset
439 short_description = ''
598
e432b61c6d74 Use Mercurial-provided infrastructure for `svn' metacommand help.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 595
diff changeset
440 ret.append(" :%s: %s" % (name, short_description))
253
c3d5c4ae9c7c Work with simple command table instead of decorators.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 247
diff changeset
441 return '\n'.join(ret) + '\n'
578
de384e4e0423 merge commands from utility_commands into svncommands
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 573
diff changeset
442
599
408869906fbf Move the 'svn' metacommand into the 'svncommands' module.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 598
diff changeset
443 def svn(ui, repo, subcommand, *args, **opts):
408869906fbf Move the 'svn' metacommand into the 'svncommands' module.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 598
diff changeset
444 '''see detailed help for list of subcommands'''
408869906fbf Move the 'svn' metacommand into the 'svncommands' module.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 598
diff changeset
445
408869906fbf Move the 'svn' metacommand into the 'svncommands' module.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 598
diff changeset
446 # guess command if prefix
408869906fbf Move the 'svn' metacommand into the 'svncommands' module.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 598
diff changeset
447 if subcommand not in table:
408869906fbf Move the 'svn' metacommand into the 'svncommands' module.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 598
diff changeset
448 candidates = []
408869906fbf Move the 'svn' metacommand into the 'svncommands' module.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 598
diff changeset
449 for c in table:
408869906fbf Move the 'svn' metacommand into the 'svncommands' module.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 598
diff changeset
450 if c.startswith(subcommand):
408869906fbf Move the 'svn' metacommand into the 'svncommands' module.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 598
diff changeset
451 candidates.append(c)
408869906fbf Move the 'svn' metacommand into the 'svncommands' module.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 598
diff changeset
452 if len(candidates) == 1:
408869906fbf Move the 'svn' metacommand into the 'svncommands' module.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 598
diff changeset
453 subcommand = candidates[0]
755
9c9565643704 svn metacommand: improved argument checking
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 754
diff changeset
454 elif not candidates:
9c9565643704 svn metacommand: improved argument checking
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 754
diff changeset
455 raise error.CommandError('svn',
9c9565643704 svn metacommand: improved argument checking
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 754
diff changeset
456 "unknown subcommand '%s'" % subcommand)
599
408869906fbf Move the 'svn' metacommand into the 'svncommands' module.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 598
diff changeset
457 else:
408869906fbf Move the 'svn' metacommand into the 'svncommands' module.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 598
diff changeset
458 raise error.AmbiguousCommand(subcommand, candidates)
408869906fbf Move the 'svn' metacommand into the 'svncommands' module.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 598
diff changeset
459
408869906fbf Move the 'svn' metacommand into the 'svncommands' module.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 598
diff changeset
460 # override subversion credentials
408869906fbf Move the 'svn' metacommand into the 'svncommands' module.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 598
diff changeset
461 for key in ('username', 'password'):
408869906fbf Move the 'svn' metacommand into the 'svncommands' module.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 598
diff changeset
462 if key in opts:
408869906fbf Move the 'svn' metacommand into the 'svncommands' module.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 598
diff changeset
463 ui.setconfig('hgsubversion', key, opts[key])
408869906fbf Move the 'svn' metacommand into the 'svncommands' module.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 598
diff changeset
464
408869906fbf Move the 'svn' metacommand into the 'svncommands' module.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 598
diff changeset
465 try:
408869906fbf Move the 'svn' metacommand into the 'svncommands' module.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 598
diff changeset
466 commandfunc = table[subcommand]
408869906fbf Move the 'svn' metacommand into the 'svncommands' module.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 598
diff changeset
467 return commandfunc(ui, args=args, repo=repo, **opts)
611
b70f7c82b9b8 svncommands: fix layering violation & tweak error messages.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 603
diff changeset
468 except svnwrap.SubversionConnectionException, e:
1555
cff81f35b31e cleanup: reference Abort from mercurial.error instead of mercurial.util
Augie Fackler <raf@durin42.com>
parents: 1503
diff changeset
469 raise error.Abort(*e.args)
599
408869906fbf Move the 'svn' metacommand into the 'svncommands' module.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 598
diff changeset
470 except TypeError:
408869906fbf Move the 'svn' metacommand into the 'svncommands' module.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 598
diff changeset
471 tb = traceback.extract_tb(sys.exc_info()[2])
408869906fbf Move the 'svn' metacommand into the 'svncommands' module.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 598
diff changeset
472 if len(tb) == 1:
408869906fbf Move the 'svn' metacommand into the 'svncommands' module.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 598
diff changeset
473 ui.status('Bad arguments for subcommand %s\n' % subcommand)
408869906fbf Move the 'svn' metacommand into the 'svncommands' module.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 598
diff changeset
474 else:
408869906fbf Move the 'svn' metacommand into the 'svncommands' module.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 598
diff changeset
475 raise
408869906fbf Move the 'svn' metacommand into the 'svncommands' module.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 598
diff changeset
476 except KeyError, e:
408869906fbf Move the 'svn' metacommand into the 'svncommands' module.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 598
diff changeset
477 tb = traceback.extract_tb(sys.exc_info()[2])
408869906fbf Move the 'svn' metacommand into the 'svncommands' module.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 598
diff changeset
478 if len(tb) == 1:
408869906fbf Move the 'svn' metacommand into the 'svncommands' module.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 598
diff changeset
479 ui.status('Unknown subcommand %s\n' % subcommand)
408869906fbf Move the 'svn' metacommand into the 'svncommands' module.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 598
diff changeset
480 else:
408869906fbf Move the 'svn' metacommand into the 'svncommands' module.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 598
diff changeset
481 raise
578
de384e4e0423 merge commands from utility_commands into svncommands
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 573
diff changeset
482
1377
2ae4fb5bfab9 svncommands: cope with aa73d6a5d9ea which removed optionalrepo
Augie Fackler <raf@durin42.com>
parents: 1317
diff changeset
483 svn.optionalrepo=True
2ae4fb5bfab9 svncommands: cope with aa73d6a5d9ea which removed optionalrepo
Augie Fackler <raf@durin42.com>
parents: 1317
diff changeset
484 svn.norepo = False
2ae4fb5bfab9 svncommands: cope with aa73d6a5d9ea which removed optionalrepo
Augie Fackler <raf@durin42.com>
parents: 1317
diff changeset
485
578
de384e4e0423 merge commands from utility_commands into svncommands
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 573
diff changeset
486 table = {
de384e4e0423 merge commands from utility_commands into svncommands
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 573
diff changeset
487 'genignore': genignore,
de384e4e0423 merge commands from utility_commands into svncommands
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 573
diff changeset
488 'info': info,
de384e4e0423 merge commands from utility_commands into svncommands
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 573
diff changeset
489 'listauthors': listauthors,
de384e4e0423 merge commands from utility_commands into svncommands
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 573
diff changeset
490 'update': update,
595
200770235bf0 svncommands: rename the `help' function to `help_'.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 580
diff changeset
491 'help': help_,
890
78db88de9622 Partial metadata rebuilding
David Schleimer <dschleimer@fb.com>
parents: 885
diff changeset
492 'updatemeta': updatemeta,
578
de384e4e0423 merge commands from utility_commands into svncommands
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 573
diff changeset
493 'rebuildmeta': rebuildmeta,
de384e4e0423 merge commands from utility_commands into svncommands
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 573
diff changeset
494 'updateexternals': svnexternals.updateexternals,
897
6bc8046e3d0a move verify to a file of its own
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 893
diff changeset
495 'verify': verify.verify,
578
de384e4e0423 merge commands from utility_commands into svncommands
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents: 573
diff changeset
496 }
599
408869906fbf Move the 'svn' metacommand into the 'svncommands' module.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 598
diff changeset
497 svn.__doc__ = _helpgen()