newline in branch name - how to recover repo

Igor Lautar igor.lautar at gmail.com
Fri Nov 27 06:09:59 CST 2009


On Fri, Nov 27, 2009 at 12:22 PM, Igor Lautar <igor.lautar at gmail.com> wrote:
> Hi All,
>
> I have a weird problem.
>
> Some history how we come to this state:
>  - we migrated from svn
>  - I've used hg convert to convert this svn repo to hg (using just
> part of whole repo)
>  - convert was done on a subdirectory (ie. not trunk but 'src' dir inside it)
>  - this was done for two branches
>  - branchmap was used to link 'src' from trunk to 'default' and the
> one from branch to 'v1' (arbitrary names)
>  - shamap was also used to properly link v1 with default
>
> How the weird problem. This was originally done on windows system and
> later moved to linux where repo was incrementally converted few times
> to sync. This is now final, as we moved to hg.
>
> However, it seams branchmap files (when moved from win to linux)
> somehow (CR/LF detection) managed to put extra newline into tag. This
> was not obvious from command-line tools (it does not display extra
> newline), but from hgtk log, I can see something like:
>
> 'default
> '
> and
> 'v1
> '
>
> It was weird to have 'default' tag show up in logs, but I (wrongly)
> ignored it. Stuff was also commited (and merged etc.) later on,
> introducing proper branch names.
>
> Now we have 4 branches:
> 'default'
> 'default
> '
> 'v1'
> 'v1
> '
>
> Interestingly enough, command line tools do not show newline,
> branchheads.cache looks like:
> <hash> tip
> <hash> default
> <hash> default
> <hash> v1
> <hash> v1
>
> and hg update [default|v1] does the wrong thing.
>
> How to fix this? I have no problem of doing complete hg convert on it
> as number of devs is small (two of us for now). Would hg convert be
> our best option?
>
> But this got me thinking. Its obviously a corner case in convert
> extension to create this, but should hg care for newline?
>
> Thx for ideas,
> Igor
>

(keeping old msg for mercurial-devel)

Should anyone be interested, hg convert preserves newline.

But the following patch did the trick:
diff -r d266aa7606ce hgext/convert/convcmd.py
--- a/hgext/convert/convcmd.py  Wed Nov 18 00:19:42 2009 +0100
+++ b/hgext/convert/convcmd.py  Fri Nov 27 12:54:10 2009 +0100
@@ -266,12 +266,13 @@
     def cachecommit(self, rev):
         commit = self.source.getcommit(rev)
         commit.author = self.authors.get(commit.author, commit.author)
-        commit.branch = self.branchmap.get(commit.branch, commit.branch)
+        commit.branch = self.branchmap.get(commit.branch,
commit.branch).strip()
         self.commitcache[rev] = commit
         return commit

     def copy(self, rev):
         commit = self.commitcache[rev]
+        commit.branch = commit.branch.strip()

         changes = self.source.getchanges(rev)
         if isinstance(changes, basestring):


More information about the Mercurial-devel mailing list