annotate util.py @ 197:43d56e973c3c

Replace a few asserts with aborts.
author Dan Villiom Podlaski Christiansen <danchr@cs.au.dk>
date Thu, 12 Feb 2009 15:08:53 +0100
parents 77812f98e250
children df4611050286
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
1 import os
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
2 import shutil
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
3
196
77812f98e250 Add a naive hg svn version command that works as long as hgsubversion is run from a checkout.
Augie Fackler <durin42@gmail.com>
parents: 195
diff changeset
4 from mercurial import hg
34
50d55c3e0d85 Some refactors of the previous change, including transparent upgrade of old-style pickled dictionaries.
Augie Fackler <durin42@gmail.com>
parents: 19
diff changeset
5 from mercurial import node
50d55c3e0d85 Some refactors of the previous change, including transparent upgrade of old-style pickled dictionaries.
Augie Fackler <durin42@gmail.com>
parents: 19
diff changeset
6
0
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
7 svn_subcommands = { }
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
8 def register_subcommand(name):
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
9 def inner(fn):
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
10 svn_subcommands[name] = fn
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
11 return fn
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
12 return inner
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
13
196
77812f98e250 Add a naive hg svn version command that works as long as hgsubversion is run from a checkout.
Augie Fackler <durin42@gmail.com>
parents: 195
diff changeset
14 svn_commands_nourl = set()
77812f98e250 Add a naive hg svn version command that works as long as hgsubversion is run from a checkout.
Augie Fackler <durin42@gmail.com>
parents: 195
diff changeset
15 def command_needs_no_url(fn):
77812f98e250 Add a naive hg svn version command that works as long as hgsubversion is run from a checkout.
Augie Fackler <durin42@gmail.com>
parents: 195
diff changeset
16 svn_commands_nourl.add(fn)
77812f98e250 Add a naive hg svn version command that works as long as hgsubversion is run from a checkout.
Augie Fackler <durin42@gmail.com>
parents: 195
diff changeset
17 return fn
77812f98e250 Add a naive hg svn version command that works as long as hgsubversion is run from a checkout.
Augie Fackler <durin42@gmail.com>
parents: 195
diff changeset
18
77812f98e250 Add a naive hg svn version command that works as long as hgsubversion is run from a checkout.
Augie Fackler <durin42@gmail.com>
parents: 195
diff changeset
19
77812f98e250 Add a naive hg svn version command that works as long as hgsubversion is run from a checkout.
Augie Fackler <durin42@gmail.com>
parents: 195
diff changeset
20 def version(ui):
77812f98e250 Add a naive hg svn version command that works as long as hgsubversion is run from a checkout.
Augie Fackler <durin42@gmail.com>
parents: 195
diff changeset
21 """Guess the version of hgsubversion.
77812f98e250 Add a naive hg svn version command that works as long as hgsubversion is run from a checkout.
Augie Fackler <durin42@gmail.com>
parents: 195
diff changeset
22 """
77812f98e250 Add a naive hg svn version command that works as long as hgsubversion is run from a checkout.
Augie Fackler <durin42@gmail.com>
parents: 195
diff changeset
23 # TODO make this say something other than "unknown" for installed hgsubversion
77812f98e250 Add a naive hg svn version command that works as long as hgsubversion is run from a checkout.
Augie Fackler <durin42@gmail.com>
parents: 195
diff changeset
24 repo = hg.repository(ui, os.path.dirname(__file__))
77812f98e250 Add a naive hg svn version command that works as long as hgsubversion is run from a checkout.
Augie Fackler <durin42@gmail.com>
parents: 195
diff changeset
25 ver = repo.dirstate.parents()[0]
77812f98e250 Add a naive hg svn version command that works as long as hgsubversion is run from a checkout.
Augie Fackler <durin42@gmail.com>
parents: 195
diff changeset
26 return node.hex(ver)[:12]
77812f98e250 Add a naive hg svn version command that works as long as hgsubversion is run from a checkout.
Augie Fackler <durin42@gmail.com>
parents: 195
diff changeset
27
0
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
28
115
ed42f6e5705a Clean up help text, document subcommands.
Luke Opperman <luke@loppear.com>
parents: 99
diff changeset
29 def generate_help():
185
57355b0e7bd1 Creating patch for documention messages.
Dan Villiom Podlaski Christiansen <danchr@cs.au.dk>
parents: 159
diff changeset
30 ret = ['hg svn ...', '',
57355b0e7bd1 Creating patch for documention messages.
Dan Villiom Podlaski Christiansen <danchr@cs.au.dk>
parents: 159
diff changeset
31 'subcommands for Subversion integration', '',
57355b0e7bd1 Creating patch for documention messages.
Dan Villiom Podlaski Christiansen <danchr@cs.au.dk>
parents: 159
diff changeset
32 'list of subcommands:', '']
115
ed42f6e5705a Clean up help text, document subcommands.
Luke Opperman <luke@loppear.com>
parents: 99
diff changeset
33
ed42f6e5705a Clean up help text, document subcommands.
Luke Opperman <luke@loppear.com>
parents: 99
diff changeset
34 for name, func in sorted(svn_subcommands.items()):
185
57355b0e7bd1 Creating patch for documention messages.
Dan Villiom Podlaski Christiansen <danchr@cs.au.dk>
parents: 159
diff changeset
35 short_description = (func.__doc__ or '').splitlines()[0]
115
ed42f6e5705a Clean up help text, document subcommands.
Luke Opperman <luke@loppear.com>
parents: 99
diff changeset
36 ret.append(" %-10s %s" % (name, short_description))
ed42f6e5705a Clean up help text, document subcommands.
Luke Opperman <luke@loppear.com>
parents: 99
diff changeset
37
ed42f6e5705a Clean up help text, document subcommands.
Luke Opperman <luke@loppear.com>
parents: 99
diff changeset
38 return "\n".join(ret) + '\n'
ed42f6e5705a Clean up help text, document subcommands.
Luke Opperman <luke@loppear.com>
parents: 99
diff changeset
39
ed42f6e5705a Clean up help text, document subcommands.
Luke Opperman <luke@loppear.com>
parents: 99
diff changeset
40
140
9ffde8662967 util: Add a command to normalize svn urls and use it in a couple of places. Test that it works and prevents failed assertions.
Augie Fackler <durin42@gmail.com>
parents: 124
diff changeset
41 def normalize_url(svn_url):
193
6e3f99ba47ec Simplify normalize_url.
Martin Geisler <mg@daimi.au.dk>
parents: 186
diff changeset
42 return svn_url.rstrip('/')
140
9ffde8662967 util: Add a command to normalize svn urls and use it in a couple of places. Test that it works and prevents failed assertions.
Augie Fackler <durin42@gmail.com>
parents: 124
diff changeset
43
9ffde8662967 util: Add a command to normalize svn urls and use it in a couple of places. Test that it works and prevents failed assertions.
Augie Fackler <durin42@gmail.com>
parents: 124
diff changeset
44
0
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
45 def wipe_all_files(hg_wc_path):
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
46 files = [f for f in os.listdir(hg_wc_path) if f != '.hg']
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
47 for f in files:
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
48 f = os.path.join(hg_wc_path, f)
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
49 if os.path.isdir(f):
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
50 shutil.rmtree(f)
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
51 else:
f2636cfed115 Initial import of hgsubversion into a public repository.
Augie Fackler <durin42@gmail.com>
parents:
diff changeset
52 os.remove(f)
34
50d55c3e0d85 Some refactors of the previous change, including transparent upgrade of old-style pickled dictionaries.
Augie Fackler <durin42@gmail.com>
parents: 19
diff changeset
53
50d55c3e0d85 Some refactors of the previous change, including transparent upgrade of old-style pickled dictionaries.
Augie Fackler <durin42@gmail.com>
parents: 19
diff changeset
54 REVMAP_FILE_VERSION = 1
50d55c3e0d85 Some refactors of the previous change, including transparent upgrade of old-style pickled dictionaries.
Augie Fackler <durin42@gmail.com>
parents: 19
diff changeset
55 def parse_revmap(revmap_filename):
50d55c3e0d85 Some refactors of the previous change, including transparent upgrade of old-style pickled dictionaries.
Augie Fackler <durin42@gmail.com>
parents: 19
diff changeset
56 revmap = {}
50d55c3e0d85 Some refactors of the previous change, including transparent upgrade of old-style pickled dictionaries.
Augie Fackler <durin42@gmail.com>
parents: 19
diff changeset
57 f = open(revmap_filename)
159
463998d266e3 parse_revmap: Stop supporting pickled revmaps. I've made enough major changes
Augie Fackler <durin42@gmail.com>
parents: 154
diff changeset
58 ver = int(f.readline())
463998d266e3 parse_revmap: Stop supporting pickled revmaps. I've made enough major changes
Augie Fackler <durin42@gmail.com>
parents: 154
diff changeset
59 if ver == 1:
463998d266e3 parse_revmap: Stop supporting pickled revmaps. I've made enough major changes
Augie Fackler <durin42@gmail.com>
parents: 154
diff changeset
60 for l in f:
463998d266e3 parse_revmap: Stop supporting pickled revmaps. I've made enough major changes
Augie Fackler <durin42@gmail.com>
parents: 154
diff changeset
61 revnum, node_hash, branch = l.split(' ', 2)
463998d266e3 parse_revmap: Stop supporting pickled revmaps. I've made enough major changes
Augie Fackler <durin42@gmail.com>
parents: 154
diff changeset
62 if branch == '\n':
463998d266e3 parse_revmap: Stop supporting pickled revmaps. I've made enough major changes
Augie Fackler <durin42@gmail.com>
parents: 154
diff changeset
63 branch = None
463998d266e3 parse_revmap: Stop supporting pickled revmaps. I've made enough major changes
Augie Fackler <durin42@gmail.com>
parents: 154
diff changeset
64 else:
463998d266e3 parse_revmap: Stop supporting pickled revmaps. I've made enough major changes
Augie Fackler <durin42@gmail.com>
parents: 154
diff changeset
65 branch = branch[:-1]
463998d266e3 parse_revmap: Stop supporting pickled revmaps. I've made enough major changes
Augie Fackler <durin42@gmail.com>
parents: 154
diff changeset
66 revmap[int(revnum), branch] = node.bin(node_hash)
34
50d55c3e0d85 Some refactors of the previous change, including transparent upgrade of old-style pickled dictionaries.
Augie Fackler <durin42@gmail.com>
parents: 19
diff changeset
67 f.close()
159
463998d266e3 parse_revmap: Stop supporting pickled revmaps. I've made enough major changes
Augie Fackler <durin42@gmail.com>
parents: 154
diff changeset
68 else: #pragma: no cover
463998d266e3 parse_revmap: Stop supporting pickled revmaps. I've made enough major changes
Augie Fackler <durin42@gmail.com>
parents: 154
diff changeset
69 print ('Your revmap was made by a newer version of hgsubversion.'
463998d266e3 parse_revmap: Stop supporting pickled revmaps. I've made enough major changes
Augie Fackler <durin42@gmail.com>
parents: 154
diff changeset
70 ' Please upgrade.')
463998d266e3 parse_revmap: Stop supporting pickled revmaps. I've made enough major changes
Augie Fackler <durin42@gmail.com>
parents: 154
diff changeset
71 raise NotImplementedError
34
50d55c3e0d85 Some refactors of the previous change, including transparent upgrade of old-style pickled dictionaries.
Augie Fackler <durin42@gmail.com>
parents: 19
diff changeset
72 return revmap
50d55c3e0d85 Some refactors of the previous change, including transparent upgrade of old-style pickled dictionaries.
Augie Fackler <durin42@gmail.com>
parents: 19
diff changeset
73
39
b3c7b844b782 Some more fixes of cases discovered in the melange repo. If anyone knows how I can reproduce a "replaced" state in Subversion, I'd love to be able to make a real test case for this code.
Augie Fackler <durin42@gmail.com>
parents: 34
diff changeset
74
b3c7b844b782 Some more fixes of cases discovered in the melange repo. If anyone knows how I can reproduce a "replaced" state in Subversion, I'd love to be able to make a real test case for this code.
Augie Fackler <durin42@gmail.com>
parents: 34
diff changeset
75 class PrefixMatch(object):
b3c7b844b782 Some more fixes of cases discovered in the melange repo. If anyone knows how I can reproduce a "replaced" state in Subversion, I'd love to be able to make a real test case for this code.
Augie Fackler <durin42@gmail.com>
parents: 34
diff changeset
76 def __init__(self, prefix):
b3c7b844b782 Some more fixes of cases discovered in the melange repo. If anyone knows how I can reproduce a "replaced" state in Subversion, I'd love to be able to make a real test case for this code.
Augie Fackler <durin42@gmail.com>
parents: 34
diff changeset
77 self.p = prefix
140
9ffde8662967 util: Add a command to normalize svn urls and use it in a couple of places. Test that it works and prevents failed assertions.
Augie Fackler <durin42@gmail.com>
parents: 124
diff changeset
78
39
b3c7b844b782 Some more fixes of cases discovered in the melange repo. If anyone knows how I can reproduce a "replaced" state in Subversion, I'd love to be able to make a real test case for this code.
Augie Fackler <durin42@gmail.com>
parents: 34
diff changeset
79 def files(self):
b3c7b844b782 Some more fixes of cases discovered in the melange repo. If anyone knows how I can reproduce a "replaced" state in Subversion, I'd love to be able to make a real test case for this code.
Augie Fackler <durin42@gmail.com>
parents: 34
diff changeset
80 return []
140
9ffde8662967 util: Add a command to normalize svn urls and use it in a couple of places. Test that it works and prevents failed assertions.
Augie Fackler <durin42@gmail.com>
parents: 124
diff changeset
81
39
b3c7b844b782 Some more fixes of cases discovered in the melange repo. If anyone knows how I can reproduce a "replaced" state in Subversion, I'd love to be able to make a real test case for this code.
Augie Fackler <durin42@gmail.com>
parents: 34
diff changeset
82 def __call__(self, fn):
b3c7b844b782 Some more fixes of cases discovered in the melange repo. If anyone knows how I can reproduce a "replaced" state in Subversion, I'd love to be able to make a real test case for this code.
Augie Fackler <durin42@gmail.com>
parents: 34
diff changeset
83 return fn.startswith(self.p)
99
1da7aafdd323 Refactored outgoing_revisions into util where it really belongs.
Augie Fackler <durin42@gmail.com>
parents: 39
diff changeset
84
152
1fde85a10f9e push: Fix the bad implementation that required modifying the dirstate to push.
Augie Fackler <durin42@gmail.com>
parents: 140
diff changeset
85 def outgoing_revisions(ui, repo, hg_editor, reverse_map, sourcerev):
99
1da7aafdd323 Refactored outgoing_revisions into util where it really belongs.
Augie Fackler <durin42@gmail.com>
parents: 39
diff changeset
86 """Given a repo and an hg_editor, determines outgoing revisions for the
1da7aafdd323 Refactored outgoing_revisions into util where it really belongs.
Augie Fackler <durin42@gmail.com>
parents: 39
diff changeset
87 current working copy state.
1da7aafdd323 Refactored outgoing_revisions into util where it really belongs.
Augie Fackler <durin42@gmail.com>
parents: 39
diff changeset
88 """
1da7aafdd323 Refactored outgoing_revisions into util where it really belongs.
Augie Fackler <durin42@gmail.com>
parents: 39
diff changeset
89 outgoing_rev_hashes = []
152
1fde85a10f9e push: Fix the bad implementation that required modifying the dirstate to push.
Augie Fackler <durin42@gmail.com>
parents: 140
diff changeset
90 if sourcerev in reverse_map:
99
1da7aafdd323 Refactored outgoing_revisions into util where it really belongs.
Augie Fackler <durin42@gmail.com>
parents: 39
diff changeset
91 return
152
1fde85a10f9e push: Fix the bad implementation that required modifying the dirstate to push.
Augie Fackler <durin42@gmail.com>
parents: 140
diff changeset
92 sourcerev = repo[sourcerev]
1fde85a10f9e push: Fix the bad implementation that required modifying the dirstate to push.
Augie Fackler <durin42@gmail.com>
parents: 140
diff changeset
93 while (not sourcerev.node() in reverse_map
1fde85a10f9e push: Fix the bad implementation that required modifying the dirstate to push.
Augie Fackler <durin42@gmail.com>
parents: 140
diff changeset
94 and sourcerev.node() != node.nullid):
1fde85a10f9e push: Fix the bad implementation that required modifying the dirstate to push.
Augie Fackler <durin42@gmail.com>
parents: 140
diff changeset
95 outgoing_rev_hashes.append(sourcerev.node())
1fde85a10f9e push: Fix the bad implementation that required modifying the dirstate to push.
Augie Fackler <durin42@gmail.com>
parents: 140
diff changeset
96 sourcerev = sourcerev.parents()
1fde85a10f9e push: Fix the bad implementation that required modifying the dirstate to push.
Augie Fackler <durin42@gmail.com>
parents: 140
diff changeset
97 assert len(sourcerev) == 1
1fde85a10f9e push: Fix the bad implementation that required modifying the dirstate to push.
Augie Fackler <durin42@gmail.com>
parents: 140
diff changeset
98 sourcerev = sourcerev[0]
1fde85a10f9e push: Fix the bad implementation that required modifying the dirstate to push.
Augie Fackler <durin42@gmail.com>
parents: 140
diff changeset
99 if sourcerev.node() != node.nullid:
99
1da7aafdd323 Refactored outgoing_revisions into util where it really belongs.
Augie Fackler <durin42@gmail.com>
parents: 39
diff changeset
100 return outgoing_rev_hashes
124
291925677a9f tag_repo: remove gentags command, extend repo.tags(), HgChangeEditor now takes either repo or repo_path
Luke Opperman <luke@loppear.com>
parents: 115
diff changeset
101
154
6fa97cfbf62f fetch: Refactor extra creation to be shared by real and diff replay.
Augie Fackler <durin42@gmail.com>
parents: 152
diff changeset
102 def build_extra(revnum, branch, uuid, subdir):
6fa97cfbf62f fetch: Refactor extra creation to be shared by real and diff replay.
Augie Fackler <durin42@gmail.com>
parents: 152
diff changeset
103 # TODO this needs to be fixed with the new revmap
6fa97cfbf62f fetch: Refactor extra creation to be shared by real and diff replay.
Augie Fackler <durin42@gmail.com>
parents: 152
diff changeset
104 extra = {}
6fa97cfbf62f fetch: Refactor extra creation to be shared by real and diff replay.
Augie Fackler <durin42@gmail.com>
parents: 152
diff changeset
105 branchpath = 'trunk'
6fa97cfbf62f fetch: Refactor extra creation to be shared by real and diff replay.
Augie Fackler <durin42@gmail.com>
parents: 152
diff changeset
106 if branch:
6fa97cfbf62f fetch: Refactor extra creation to be shared by real and diff replay.
Augie Fackler <durin42@gmail.com>
parents: 152
diff changeset
107 extra['branch'] = branch
6fa97cfbf62f fetch: Refactor extra creation to be shared by real and diff replay.
Augie Fackler <durin42@gmail.com>
parents: 152
diff changeset
108 branchpath = 'branches/%s' % branch
6fa97cfbf62f fetch: Refactor extra creation to be shared by real and diff replay.
Augie Fackler <durin42@gmail.com>
parents: 152
diff changeset
109 if subdir and subdir[-1] == '/':
6fa97cfbf62f fetch: Refactor extra creation to be shared by real and diff replay.
Augie Fackler <durin42@gmail.com>
parents: 152
diff changeset
110 subdir = subdir[:-1]
6fa97cfbf62f fetch: Refactor extra creation to be shared by real and diff replay.
Augie Fackler <durin42@gmail.com>
parents: 152
diff changeset
111 if subdir and subdir[0] != '/':
6fa97cfbf62f fetch: Refactor extra creation to be shared by real and diff replay.
Augie Fackler <durin42@gmail.com>
parents: 152
diff changeset
112 subdir = '/' + subdir
6fa97cfbf62f fetch: Refactor extra creation to be shared by real and diff replay.
Augie Fackler <durin42@gmail.com>
parents: 152
diff changeset
113 extra['convert_revision'] = 'svn:%(uuid)s%(path)s@%(rev)s' % {
6fa97cfbf62f fetch: Refactor extra creation to be shared by real and diff replay.
Augie Fackler <durin42@gmail.com>
parents: 152
diff changeset
114 'uuid': uuid,
6fa97cfbf62f fetch: Refactor extra creation to be shared by real and diff replay.
Augie Fackler <durin42@gmail.com>
parents: 152
diff changeset
115 'path': '%s/%s' % (subdir , branchpath),
6fa97cfbf62f fetch: Refactor extra creation to be shared by real and diff replay.
Augie Fackler <durin42@gmail.com>
parents: 152
diff changeset
116 'rev': revnum,
6fa97cfbf62f fetch: Refactor extra creation to be shared by real and diff replay.
Augie Fackler <durin42@gmail.com>
parents: 152
diff changeset
117 }
6fa97cfbf62f fetch: Refactor extra creation to be shared by real and diff replay.
Augie Fackler <durin42@gmail.com>
parents: 152
diff changeset
118 return extra
6fa97cfbf62f fetch: Refactor extra creation to be shared by real and diff replay.
Augie Fackler <durin42@gmail.com>
parents: 152
diff changeset
119
124
291925677a9f tag_repo: remove gentags command, extend repo.tags(), HgChangeEditor now takes either repo or repo_path
Luke Opperman <luke@loppear.com>
parents: 115
diff changeset
120
291925677a9f tag_repo: remove gentags command, extend repo.tags(), HgChangeEditor now takes either repo or repo_path
Luke Opperman <luke@loppear.com>
parents: 115
diff changeset
121 def is_svn_repo(repo):
291925677a9f tag_repo: remove gentags command, extend repo.tags(), HgChangeEditor now takes either repo or repo_path
Luke Opperman <luke@loppear.com>
parents: 115
diff changeset
122 return os.path.exists(os.path.join(repo.path, 'svn'))
186
6266ba36ee15 Create patch to make normal output much less verbose…
Dan Villiom Podlaski Christiansen <danchr@cs.au.dk>
parents: 185
diff changeset
123
6266ba36ee15 Create patch to make normal output much less verbose…
Dan Villiom Podlaski Christiansen <danchr@cs.au.dk>
parents: 185
diff changeset
124 default_commit_msg = '*** empty log message ***'
6266ba36ee15 Create patch to make normal output much less verbose…
Dan Villiom Podlaski Christiansen <danchr@cs.au.dk>
parents: 185
diff changeset
125
6266ba36ee15 Create patch to make normal output much less verbose…
Dan Villiom Podlaski Christiansen <danchr@cs.au.dk>
parents: 185
diff changeset
126 def describe_revision(r):
6266ba36ee15 Create patch to make normal output much less verbose…
Dan Villiom Podlaski Christiansen <danchr@cs.au.dk>
parents: 185
diff changeset
127 try:
6266ba36ee15 Create patch to make normal output much less verbose…
Dan Villiom Podlaski Christiansen <danchr@cs.au.dk>
parents: 185
diff changeset
128 msg = [s for s in map(str.strip, r.message.splitlines()) if s][0]
6266ba36ee15 Create patch to make normal output much less verbose…
Dan Villiom Podlaski Christiansen <danchr@cs.au.dk>
parents: 185
diff changeset
129 except:
6266ba36ee15 Create patch to make normal output much less verbose…
Dan Villiom Podlaski Christiansen <danchr@cs.au.dk>
parents: 185
diff changeset
130 msg = default_commit_msg
6266ba36ee15 Create patch to make normal output much less verbose…
Dan Villiom Podlaski Christiansen <danchr@cs.au.dk>
parents: 185
diff changeset
131
6266ba36ee15 Create patch to make normal output much less verbose…
Dan Villiom Podlaski Christiansen <danchr@cs.au.dk>
parents: 185
diff changeset
132 return ('[r%d] %s: %s' % (r.revnum, r.author, msg))[:80] + '\n'
6266ba36ee15 Create patch to make normal output much less verbose…
Dan Villiom Podlaski Christiansen <danchr@cs.au.dk>
parents: 185
diff changeset
133
6266ba36ee15 Create patch to make normal output much less verbose…
Dan Villiom Podlaski Christiansen <danchr@cs.au.dk>
parents: 185
diff changeset
134 def describe_commit(h, b):
6266ba36ee15 Create patch to make normal output much less verbose…
Dan Villiom Podlaski Christiansen <danchr@cs.au.dk>
parents: 185
diff changeset
135 return ' committed to "%s" as %s\n' % ((b or 'default'), node.short(h))