Patchwork convert: use 'default' for specifying branch name in branchmap (issue4753)

login
register
mail settings
Submitter Eugene Baranov
Date July 14, 2015, 1:42 p.m.
Message ID <f516ac1d4b9bbbcd4576.1436881365@waste.org>
Download mbox | patch
Permalink /patch/9970/
State Superseded
Headers show

Comments

Eugene Baranov - July 14, 2015, 1:42 p.m.
# HG changeset patch
# User Eugene Baranov <eug.baranov@gmail.com>
# Date 1436881256 -3600
#      Tue Jul 14 14:40:56 2015 +0100
# Node ID f516ac1d4b9bbbcd45763c1b008c805e60b8bfbf
# Parent  35fa7c77c754aa4d156c42abfdb61ca178468872
convert: use 'default' for specifying branch name in branchmap (issue4753)

A fix for issue2653 with 1d155582a8ea introduced a discrepancy how default
branch should be denoted when converting with branchmap from different SCM.
E.g. for Git and Mercurial you need to use 'default' whilst for Perforce and
SVN you had to use 'None'. This changeset unifies 'default' for such purposes.
Matt Mackall - July 14, 2015, 11:59 p.m.
On Tue, 2015-07-14 at 08:42 -0500, Eugene Baranov wrote:
> # HG changeset patch
> # User Eugene Baranov <eug.baranov@gmail.com>
> # Date 1436881256 -3600
> #      Tue Jul 14 14:40:56 2015 +0100
> # Node ID f516ac1d4b9bbbcd45763c1b008c805e60b8bfbf
> # Parent  35fa7c77c754aa4d156c42abfdb61ca178468872
> convert: use 'default' for specifying branch name in branchmap (issue4753)
> 
> A fix for issue2653 with 1d155582a8ea introduced a discrepancy how default
> branch should be denoted when converting with branchmap from different SCM.
> E.g. for Git and Mercurial you need to use 'default' whilst for Perforce and
> SVN you had to use 'None'. This changeset unifies 'default' for such purposes.

>    $ cat > branchmap <<EOF
> -  > None hgtrunk
> +  > default hgtrunk

Doesn't this break anyone who's using relying on this today?

Patch

diff --git a/hgext/convert/convcmd.py b/hgext/convert/convcmd.py
--- a/hgext/convert/convcmd.py
+++ b/hgext/convert/convcmd.py
@@ -379,10 +379,10 @@ 
         commit.author = self.authors.get(commit.author, commit.author)
         # If commit.branch is None, this commit is coming from the source
         # repository's default branch and destined for the default branch in the
-        # destination repository. For such commits, passing a literal "None"
-        # string to branchmap.get() below allows the user to map "None" to an
+        # destination repository. For such commits, passing a literal "default"
+        # string to branchmap.get() below allows the user to map "default" to an
         # alternate default branch in the destination repository.
-        commit.branch = self.branchmap.get(str(commit.branch), commit.branch)
+        commit.branch = self.branchmap.get(commit.branch or 'default', commit.branch)
         self.commitcache[rev] = commit
         return commit
 
diff --git a/hgext/convert/p4.py b/hgext/convert/p4.py
--- a/hgext/convert/p4.py
+++ b/hgext/convert/p4.py
@@ -126,7 +126,7 @@ 
             date = (int(d["time"]), 0)     # timezone not set
             c = commit(author=self.recode(d["user"]),
                        date=util.datestr(date, '%Y-%m-%d %H:%M:%S %1%2'),
-                       parents=parents, desc=desc, branch='',
+                       parents=parents, desc=desc, branch=None,
                        extra={"p4": change})
 
             files = []
diff --git a/tests/test-convert-svn-branches.t b/tests/test-convert-svn-branches.t
--- a/tests/test-convert-svn-branches.t
+++ b/tests/test-convert-svn-branches.t
@@ -99,7 +99,7 @@ 
 Convert 'trunk' to branch other than 'default'
 
   $ cat > branchmap <<EOF
-  > None hgtrunk
+  > default hgtrunk
   > 
   > 
   > EOF
@@ -121,9 +121,9 @@ 
   0 last change to a
 
   $ cd C-hg
-  $ hg branches
-  hgtrunk                       10:745f063703b4
-  old                            9:aa50d7b8d922
-  old2                           8:c85a22267b6e (inactive)
+  $ hg branches --template '{branch}\n'
+  hgtrunk
+  old
+  old2
   $ cd ..