annotate hgsubversion/svncommands.py @ 1572:51e105c7f0c6

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