changeset 186:6266ba36ee15

Create patch to make normal output much less verboseā€¦
author Dan Villiom Podlaski Christiansen <danchr@cs.au.dk>
date Sat, 17 Jan 2009 15:30:38 -0600
parents 57355b0e7bd1
children 68e506bc3a43
files fetch_command.py hg_delta_editor.py util.py
diffstat 3 files changed, 44 insertions(+), 36 deletions(-) [+]
line wrap: on
line diff
--- a/fetch_command.py
+++ b/fetch_command.py
@@ -79,7 +79,7 @@ def fetch_revisions(ui, svn_url, hg_repo
             converted = False
             while not converted and tries < 3:
                 try:
-                    ui.status('converting %s\n' % r)
+                    ui.status(util.describe_revision(r))
                     if have_replay:
                         try:
                             replay_convert_rev(hg_editor, svn, r)
@@ -123,7 +123,7 @@ def replay_convert_rev(hg_editor, svn, r
         files_to_grab = set()
         rootpath = svn.subdir and svn.subdir[1:] or ''
         for p in hg_editor.missing_plaintexts:
-            hg_editor.ui.status('.')
+            hg_editor.ui.note('.')
             hg_editor.ui.flush()
             if p[-1] == '/':
                 dirpath = p[len(rootpath):]
@@ -132,16 +132,16 @@ def replay_convert_rev(hg_editor, svn, r
                                       if k == 'f'])
             else:
                 files_to_grab.add(p[len(rootpath):])
-        hg_editor.ui.status('\nFetching files...\n')
+        hg_editor.ui.note('\nFetching files...\n')
         for p in files_to_grab:
-            hg_editor.ui.status('.')
+            hg_editor.ui.note('.')
             hg_editor.ui.flush()
             cleanup_file_handles(svn, i)
             i += 1
             data, mode = svn.get_file(p, r.revnum)
             hg_editor.set_file(p, data, 'x' in mode, 'l' in mode)
         hg_editor.missing_plaintexts = set()
-        hg_editor.ui.status('\n')
+        hg_editor.ui.note('\n')
     hg_editor.commit_current_delta()
 
 
@@ -268,7 +268,7 @@ def stupid_diff_branchrev(ui, svn, hg_ed
             # full fetch on files that had problems.
             raise BadPatchApply('patching failed')
         for x in files_data.iterkeys():
-            ui.status('M  %s\n' % x)
+            ui.note('M  %s\n' % x)
         # if this patch didn't apply right, fall back to exporting the
         # entire rev.
         if patch_st == -1:
@@ -586,7 +586,7 @@ def stupid_svn_server_pull_rev(ui, svn, 
                     assert f[0] != '/'
             current_ctx = context.memctx(hg_editor.repo,
                                          [parentctx.node(), revlog.nullid],
-                                         r.message or '...',
+                                         r.message or util.default_commit_msg,
                                          files_touched,
                                          filectxfn,
                                          hg_editor.authorforsvnauthor(r.author),
@@ -595,8 +595,7 @@ def stupid_svn_server_pull_rev(ui, svn, 
             ha = hg_editor.repo.commitctx(current_ctx)
             hg_editor.add_to_revmap(r.revnum, b, ha)
             hg_editor._save_metadata()
-            ui.status('committed as %s on branch %s\n' %
-                      (node.hex(ha),  b or 'default'))
+            ui.status(util.describe_commit(ha, b))
     # These are branches which would have an 'R' status in svn log. This means they were
     # replaced by some other branch, so we need to verify they get marked as closed.
     for branch in check_deleted_branches:
@@ -624,7 +623,7 @@ def stupid_svn_server_pull_rev(ui, svn, 
         parents = (parent, closed)
         current_ctx = context.memctx(hg_editor.repo,
                                      parents,
-                                     r.message or '...',
+                                     r.message or util.default_commit_msg,
                                      files_touched,
                                      filectxfn,
                                      hg_editor.authorforsvnauthor(r.author),
--- a/hg_delta_editor.py
+++ b/hg_delta_editor.py
@@ -221,7 +221,7 @@ class HgChangeReceiver(delta.Editor):
         self.current_files[path] = ''
         self.current_files_exec[path] = False
         self.current_files_symlink[path] = False
-        self.ui.status('D %s\n' % path)
+        self.ui.note('D %s\n' % path)
 
     def _normalize_path(self, path):
         '''Normalize a path to strip of leading slashes and our subdir if we
@@ -525,8 +525,8 @@ class HgChangeReceiver(delta.Editor):
                                          date,
                                          extra)
             new_hash = self.repo.commitctx(current_ctx)
-            self.ui.status('committed as %s on branch %s\n' %
-                           (node.hex(new_hash), (branch or 'default')))
+
+            self.ui.status(our_util.describe_commit(new_hash, branch))
             if (rev.revnum, branch) not in self.revmap:
                 self.add_to_revmap(rev.revnum, branch, new_hash)
         # now we handle branches that need to be committed without any files
@@ -552,8 +552,7 @@ class HgChangeReceiver(delta.Editor):
                                          date,
                                          extra)
             new_hash = self.repo.commitctx(current_ctx)
-            self.ui.status('committed as %s on branch %s\n' %
-                           (node.hex(new_hash), (branch or 'default')))
+            self.ui.status(our_util.describe_commit(new_hash, branch))
             if (rev.revnum, branch) not in self.revmap:
                 self.add_to_revmap(rev.revnum, branch, new_hash)
         self.clear_current_info()
@@ -564,9 +563,7 @@ class HgChangeReceiver(delta.Editor):
         return '%s%s' %(author, self.author_host)
 
     def readauthors(self, authorfile):
-        self.ui.status(
-            ('Reading authormap %s\n')
-            % authorfile)
+        self.ui.note(('Reading authormap from %s\n') % authorfile)
         f = open(authorfile, 'r')
         for line in f:
             if not line.strip():
@@ -576,12 +573,12 @@ class HgChangeReceiver(delta.Editor):
                 srcauth = srcauth.strip()
                 dstauth = dstauth.strip()
                 if srcauth in self.authors and dstauth != self.authors[srcauth]:
-                    self.ui.status(
-                        ('Overriding mapping for author %s, was %s, now %s\n')
-                        % (srcauth, self.authors[srcauth], dstauth))
+                    self.ui.status(('Overriding author mapping for "%s" ' +
+                                    'from "%s" to "%s"\n')
+                                   % (srcauth, self.authors[srcauth], dstauth))
                 else:
-                    self.ui.debug(('Mapping author %s to %s\n')
-                        % (srcauth, dstauth))
+                    self.ui.debug(('Mapping author "%s" to "%s"\n')
+                                  % (srcauth, dstauth))
                     self.authors[srcauth] = dstauth
             except IndexError:
                 self.ui.warn(
@@ -590,29 +587,28 @@ class HgChangeReceiver(delta.Editor):
         f.close()
 
     def writeauthors(self):
+        self.ui.debug(('Writing author map to %s\n') % self.authors_file)
         f = open(self.authors_file, 'w+')
-        self.ui.status(
-            ('Writing author map file %s\n')
-            % self.authors_file)
         for author in self.authors:
             f.write("%s=%s\n" % (author, self.authors[author]))
         f.close()
 
     def readfilemap(self, filemapfile):
-        self.ui.status(
-            ('Reading filemap %s\n')
+        self.ui.note(
+            ('Reading file map from %s\n')
             % filemapfile)
         def addpathtomap(path, mapping, mapname):
             if path in mapping:
-                self.ui.warn(
-                    ('%d alreading in %s list\n')
-                    % (path, mapname))
+                self.ui.warn(('Duplicate %s entry in %s: "%d"\n') %
+                             (mapname, filemapfile, path))
             else:
+                self.ui.debug(('%sing %s\n') %
+                              (mapname.capitalize().strip('e'), path))
                 mapping[path] = path
-        
+
         f = open(filemapfile, 'r')
         for line in f:
-            if line.strip() == '':
+            if line.strip() == '' or line.strip()[0] == '#':
                 continue
             try:
                 cmd, path = line.split(' ', 1)
@@ -706,7 +702,7 @@ class HgChangeReceiver(delta.Editor):
         fpath, branch = self._path_and_branch_for_path(path)
         if fpath:
             self.current_file = path
-            self.ui.status('M %s\n' % path)
+            self.ui.note('M %s\n' % path)
             if base_revision != -1:
                 self.base_revision = base_revision
             else:
@@ -750,9 +746,9 @@ class HgChangeReceiver(delta.Editor):
         self.current_file = path
         self.should_edit_most_recent_plaintext = False
         if not copyfrom_path:
-            self.ui.status('A %s\n' % path)
+            self.ui.note('A %s\n' % path)
             return
-        self.ui.status('A+ %s\n' % path)
+        self.ui.note('A+ %s\n' % path)
         (from_file,
          from_branch) = self._path_and_branch_for_path(copyfrom_path)
         if not from_file:
--- a/util.py
+++ b/util.py
@@ -109,3 +109,16 @@ def build_extra(revnum, branch, uuid, su
 
 def is_svn_repo(repo):
     return os.path.exists(os.path.join(repo.path, 'svn'))
+
+default_commit_msg = '*** empty log message ***'
+
+def describe_revision(r):
+    try:
+        msg = [s for s in map(str.strip, r.message.splitlines()) if s][0]
+    except:
+        msg = default_commit_msg
+
+    return ('[r%d] %s: %s' % (r.revnum, r.author, msg))[:80] + '\n'
+
+def describe_commit(h, b):
+    return ' committed to "%s" as %s\n' % ((b or 'default'), node.short(h))