changeset 329:235022089da6

merge with stable
author Dan Villiom Podlaski Christiansen <danchr@gmail.com>
date Sat, 09 May 2009 12:36:17 +0200
parents 48ec2d62dc29 (current diff) 067914ecb4eb (diff)
children 5f8f2fd4fd54
files __init__.py hg_delta_editor.py wrappers.py
diffstat 7 files changed, 71 insertions(+), 11 deletions(-) [+]
line wrap: on
line diff
--- a/cmdutil.py
+++ b/cmdutil.py
@@ -245,7 +245,7 @@ def commit_from_rev(ui, repo, rev_ctx, h
     for d in deleteddirs2:
         pos = d.rfind('/')
         if pos >= 0 and d[:pos] in deleteddirs:
-            deleteddirs.remove(d[:pos])
+            deleteddirs.remove(d)
 
     newcopies = {}
     for source, dest in copies.iteritems():
--- a/hg_delta_editor.py
+++ b/hg_delta_editor.py
@@ -640,6 +640,9 @@ class HgChangeReceiver(delta.Editor):
             def del_all_files(*args):
                 raise IOError
             files = parentctx.manifest().keys()
+            extra = {}
+            if not self.opts.get('svn_no_branchnames', False):
+                extra['branch'] = 'closed-branches'
             current_ctx = context.memctx(self.repo,
                                          parents,
                                          rev.message or ' ',
@@ -647,7 +650,7 @@ class HgChangeReceiver(delta.Editor):
                                          del_all_files,
                                          self.authors[rev.author],
                                          date,
-                                         {'branch': 'closed-branches'})
+                                         extra)
             new_hash = self.repo.commitctx(current_ctx)
             self.ui.status('Marked branch %s as closed.\n' % (branch or
                                                               'default'))
@@ -693,6 +696,8 @@ class HgChangeReceiver(delta.Editor):
                                           data=data,
                                           islink=is_link, isexec=is_exec,
                                           copied=copied)
+            if self.opts.get('svn_no_branchnames', False):
+                extra.pop('branch', None)
             current_ctx = context.memctx(self.repo,
                                          parents,
                                          rev.message or '...',
@@ -720,6 +725,8 @@ class HgChangeReceiver(delta.Editor):
             extra = util.build_extra(rev.revnum, branch,
                                      open(self.uuid_file).read(),
                                      self.subdir)
+            if self.opts.get('svn_no_branchnames', False):
+                extra.pop('branch', None)
             current_ctx = context.memctx(self.repo,
                                          (ha, node.nullid),
                                          rev.message or ' ',
@@ -862,7 +869,7 @@ class HgChangeReceiver(delta.Editor):
                 parent = self.get_parent_revision(baserev + 1, branch)
                 self.load_base_from_ctx(path, fpath, self.repo.changectx(parent))
         else:
-            self.ui.warn('WARNING: Opening non-existant file %s\n' % path)
+            self.ui.debug('WARNING: Opening non-existant file %s\n' % path)
     open_file = stash_exception_on_self(open_file)
 
     def aresamefiles(self, parentctx, childctx, files):
--- a/maps.py
+++ b/maps.py
@@ -6,16 +6,16 @@ from mercurial import util as hgutil
 class AuthorMap(dict):
     '''A mapping from Subversion-style authors to Mercurial-style
     authors, and back. The data is stored persistently on disk.
-    
+
     If the 'hgsubversion.defaultauthors' configuration option is set to false,
     attempting to obtain an unknown author will fail with an Abort.
     '''
 
     def __init__(self, ui, path, defaulthost=None):
         '''Initialise a new AuthorMap.
-        
+
         The ui argument is used to print diagnostic messages.
-        
+
         The path argument is the location of the backing store,
         typically .hg/authormap.
         '''
@@ -70,9 +70,8 @@ class AuthorMap(dict):
         if author in self:
             result = self.super.__getitem__(author)
         elif self.ui.configbool('hgsubversion', 'defaultauthors', True):
-            # TODO: should we treat missing authors specially?
             self[author] = result = '%s%s' % (author, self.defaulthost)
-            self.ui.warn('Substituting author "%s" for default "%s"\n'
+            self.ui.note('Substituting author "%s" for default "%s"\n'
                          % (author, result))
         else:
             raise hgutil.Abort('Author %s has no entry in the author map!'
--- a/stupid.py
+++ b/stupid.py
@@ -526,8 +526,10 @@ def svn_server_pull_rev(ui, svn, hg_edit
                                          hg_editor.authors[r.author],
                                          date,
                                          extra)
-            ha = hg_editor.repo.commitctx(current_ctx)
             branch = extra.get('branch', None)
+            if hg_editor.opts.get('svn_no_branchnames', False):
+                extra.pop('branch', None)
+            ha = hg_editor.repo.commitctx(current_ctx)
             if not branch in hg_editor.branches:
                 hg_editor.branches[branch] = None, 0, r.revnum
             hg_editor.add_to_revmap(r.revnum, b, ha)
@@ -558,6 +560,9 @@ def svn_server_pull_rev(ui, svn, hg_edit
         if 'closed-branches' in hg_editor.repo.branchtags():
             closed = hg_editor.repo['closed-branches'].node()
         parents = (parent, closed)
+        extra = {}
+        if not hg_editor.opts.get('svn_no_branchnames', False):
+                extra['branch'] = 'closed-branches'
         current_ctx = context.memctx(hg_editor.repo,
                                      parents,
                                      r.message or util.default_commit_msg,
@@ -565,7 +570,7 @@ def svn_server_pull_rev(ui, svn, hg_edit
                                      filectxfn,
                                      hg_editor.authors[r.author],
                                      date,
-                                     {'branch': 'closed-branches'})
+                                     extra)
         ha = hg_editor.repo.commitctx(current_ctx)
         ui.status('Marked branch %s as closed.\n' % (b or 'default'))
         hg_editor._save_metadata()
--- a/tests/test_push_dirs.py
+++ b/tests/test_push_dirs.py
@@ -47,7 +47,7 @@ class TestPushDirectories(test_util.Test
         self.commitchanges(changes)
         self.pushrevisions()
         self.assertEqual(self.svnls('trunk'),
-                         ['d2', 'd2/b', 'd31', 'd31/d32', 'd31/d32/a', 'd31/d32/d33'])
+                         ['d2', 'd2/b', 'd31', 'd31/d32', 'd31/d32/a', ])
 
 
 class TestPushDirsNotAtRoot(test_util.TestBase):
--- a/tests/test_push_renames.py
+++ b/tests/test_push_renames.py
@@ -49,6 +49,54 @@ class TestPushRenames(test_util.TestBase
         # self._debug_print_copies(tip)
         self.assertchanges(changes, tip)
 
+    def test_push_rename_tree(self):
+        repo = self.repo
+
+        changes = [
+            ('geek/alpha', 'geek/alpha', 'content',),
+            ('geek/beta', 'geek/beta', 'content',),
+            ('geek/delta', 'geek/delta', 'content',),
+            ('geek/gamma', 'geek/gamma', 'content',),
+            ('geek/later/pi', 'geek/later/pi', 'content geek/later/pi',),
+            ('geek/later/rho', 'geek/later/rho', 'content geek/later/rho', ),
+            ('geek/other/blah', 'geek/other/blah', 'content geek/other/blah', ),
+            ('geek/other/another/layer', 'geek/other/another/layer', 'content deep file', ),
+            ]
+
+        self.commitchanges(changes)
+        self.pushrevisions()
+        self.assertchanges(changes, self.repo['tip'])
+
+        changes = [
+            # rename (copy + remove) all of geek to greek
+            ('geek/alpha', 'greek/alpha', None, ),
+            ('geek/beta', 'greek/beta', None, ),
+            ('geek/delta', 'greek/delta', None, ),
+            ('geek/gamma', 'greek/gamma', None, ),
+            ('geek/later/pi', 'greek/later/pi', None, ),
+            ('geek/later/rho', 'greek/later/rho', None, ),
+            ('geek/other/blah', 'greek/other/blah', None, ),
+            ('geek/other/another/layer', 'greek/other/another/layer', None, ),
+
+            ('geek/alpha', None, None, ),
+            ('geek/beta', None, None, ),
+            ('geek/delta', None, None, ),
+            ('geek/gamma', None, None, ),
+            ('geek/later/pi', None, None, ),
+            ('geek/later/rho', None, None, ),
+            ('geek/other/blah', None, None, ),
+            ('geek/other/another/layer', None, None, ),
+            ]
+        self.commitchanges(changes)
+        self.pushrevisions()
+        # print '\n'.join(sorted(self.svnls('trunk')))
+        assert reduce(lambda x, y: x and y,
+                      ('geek' not in f for f in self.svnls('trunk'))),(
+            'This failure means rename of an entire tree is broken.'
+            ' There is a print on the preceding line commented out '
+            'that should help you.')
+
+
 def suite():
     all = [unittest.TestLoader().loadTestsFromTestCase(TestPushRenames),
           ]
--- a/wrappers.py
+++ b/wrappers.py
@@ -283,6 +283,7 @@ def pull(orig, ui, repo, source="default
                                                      tag_locations=tag_locations,
                                                      authors=authors,
                                                      filemap=filemap)
+    hg_editor.opts = opts
     if os.path.exists(hg_editor.uuid_file):
         uuid = open(hg_editor.uuid_file).read()
         assert uuid == svn.uuid