annotate hgsubversion/svncommands.py @ 1466:16242cec256f

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