changeset 4204:f9bbcebcacea

"default" is the default branch name
author Alexis S. L. Carvalho <alexis@cecm.usp.br>
date Tue, 13 Mar 2007 15:02:33 -0300
parents fc12ac3755d5
children a7af0eeae8a3
files mercurial/changelog.py mercurial/cmdutil.py mercurial/commands.py mercurial/context.py mercurial/localrepo.py tests/test-encoding.out tests/test-globalopts.out tests/test-mq-caches.out tests/test-newbranch.out
diffstat 9 files changed, 33 insertions(+), 26 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/changelog.py
+++ b/mercurial/changelog.py
@@ -59,7 +59,7 @@ class changelog(revlog):
         changelog v0 doesn't use extra
         """
         if not text:
-            return (nullid, "", (0, 0), [], "", {})
+            return (nullid, "", (0, 0), [], "", {'branch': 'default'})
         last = text.index("\n\n")
         desc = util.tolocal(text[last + 2:])
         l = text[:last].split('\n')
@@ -79,6 +79,8 @@ class changelog(revlog):
             time, timezone, extra = extra_data
             time, timezone = float(time), int(timezone)
             extra = self.decode_extra(extra)
+        if not extra.get('branch'):
+            extra['branch'] = 'default'
         files = l[3:]
         return (manifest, user, (time, timezone), files, desc, extra)
 
@@ -94,6 +96,8 @@ class changelog(revlog):
             parseddate = "%d %d" % util.parsedate(date)
         else:
             parseddate = "%d %d" % util.makedate()
+        if extra and extra.get("branch") in ("default", ""):
+            del extra["branch"]
         if extra:
             extra = self.encode_extra(extra)
             parseddate = "%s %s" % (parseddate, extra)
--- a/mercurial/cmdutil.py
+++ b/mercurial/cmdutil.py
@@ -262,7 +262,8 @@ class changeset_printer(object):
 
         self.ui.write(_("changeset:   %d:%s\n") % (rev, hexfunc(changenode)))
 
-        if branch:
+        # don't show the default branch name
+        if branch != 'default':
             branch = util.tolocal(branch)
             self.ui.write(_("branch:      %s\n") % branch)
         for tag in self.repo.nodetags(changenode):
@@ -406,7 +407,7 @@ class changeset_templater(changeset_prin
 
         def showbranches(**args):
             branch = changes[5].get("branch")
-            if branch:
+            if branch != 'default':
                 branch = util.tolocal(branch)
                 return showlist('branch', [branch], plural='branches', **args)
             # add old style branches if requested
--- a/mercurial/commands.py
+++ b/mercurial/commands.py
@@ -1447,7 +1447,7 @@ def identify(ui, repo):
     if not ui.quiet:
 
         branch = util.tolocal(repo.workingctx().branch())
-        if branch:
+        if branch != 'default':
             output.append("(%s)" % branch)
 
         # multiple tags for a single parent separated by '/'
--- a/mercurial/context.py
+++ b/mercurial/context.py
@@ -413,9 +413,9 @@ class workingctx(changectx):
     def clean(self): return self._status[5]
     def branch(self):
         try:
-            return self._repo.opener("branch").read().strip()
+            return self._repo.opener("branch").read().strip() or "default"
         except IOError:
-            return ""
+            return "default"
 
     def parents(self):
         """return contexts for each parent changeset"""
--- a/mercurial/localrepo.py
+++ b/mercurial/localrepo.py
@@ -17,7 +17,7 @@ demandload(globals(), "os revlog time ut
 class localrepository(repo.repository):
     capabilities = ('lookup', 'changegroupsubset')
     supported = ('revlogv1', 'store')
-    branchcache_features = ('unnamed',)
+    branchcache_features = ('default',)
 
     def __del__(self):
         self.transhandle = None
@@ -727,7 +727,7 @@ class localrepository(repo.repository):
             branchname = ""
 
         if use_dirstate:
-            oldname = c1[5].get("branch", "") # stored in UTF-8
+            oldname = c1[5].get("branch") or "default" # stored in UTF-8
             if not commit and not remove and not force and p2 == nullid and \
                    branchname == oldname:
                 self.ui.status(_("nothing changed\n"))
--- a/tests/test-encoding.out
+++ b/tests/test-encoding.out
@@ -126,13 +126,13 @@ tip                                5:db5
 é                                  3:770b9b11621d
 % ascii
 ?                              5:db5520b4645f
-                               4:9cff3c980b58
+default                        4:9cff3c980b58
 % latin-1
 é                              5:db5520b4645f
-                               4:9cff3c980b58
+default                        4:9cff3c980b58
 % utf-8
 é                              5:db5520b4645f
-                               4:9cff3c980b58
+default                        4:9cff3c980b58
 % utf-8
 changeset:   5:db5520b4645f
 branch:      é
--- a/tests/test-globalopts.out
+++ b/tests/test-globalopts.out
@@ -91,6 +91,7 @@ manifest:    1:23226e7a252cacdc2d99e4fbd
 user:        test
 date:        Thu Jan 01 00:00:01 1970 +0000
 files+:      b
+extra:       branch=default
 description:
 b
 
@@ -102,6 +103,7 @@ manifest:    0:a0c8bcbbb45c63b90b70ad007
 user:        test
 date:        Thu Jan 01 00:00:01 1970 +0000
 files+:      a
+extra:       branch=default
 description:
 a
 
--- a/tests/test-mq-caches.out
+++ b/tests/test-mq-caches.out
@@ -7,7 +7,7 @@ No .hg/branches.cache
 # some regular revisions
 Patch queue now empty
 tip: 1
- features: unnamed
+ features: default
 3f910abad313ff802d3a23a7529433872df9b3ae 1
 3f910abad313ff802d3a23a7529433872df9b3ae bar
 9539f35bdc80732cc9a3f84e46508f1ed1ec8cff foo
@@ -16,12 +16,12 @@ 9539f35bdc80732cc9a3f84e46508f1ed1ec8cff
 applying p1
 Now at: p1
 tip: 2
- features: unnamed
+ features: default
 3f910abad313ff802d3a23a7529433872df9b3ae 1
 3f910abad313ff802d3a23a7529433872df9b3ae bar
 9539f35bdc80732cc9a3f84e46508f1ed1ec8cff foo
 tip: 3
- features: unnamed
+ features: default
 3f910abad313ff802d3a23a7529433872df9b3ae 1
 3f910abad313ff802d3a23a7529433872df9b3ae bar
 9539f35bdc80732cc9a3f84e46508f1ed1ec8cff foo
@@ -30,7 +30,7 @@ branch bar: 2
 
 # removing the cache
 tip: 3
- features: unnamed
+ features: default
 3f910abad313ff802d3a23a7529433872df9b3ae 1
 3f910abad313ff802d3a23a7529433872df9b3ae bar
 9539f35bdc80732cc9a3f84e46508f1ed1ec8cff foo
@@ -39,7 +39,7 @@ branch bar: 2
 
 # importing rev 1 (the cache now ends in one of the patches)
 tip: 3
- features: unnamed
+ features: default
 3f910abad313ff802d3a23a7529433872df9b3ae 1
 3f910abad313ff802d3a23a7529433872df9b3ae bar
 9539f35bdc80732cc9a3f84e46508f1ed1ec8cff foo
@@ -54,6 +54,6 @@ applying p1
 applying p2
 Now at: p2
 tip: 3
- features: unnamed
+ features: default
 9539f35bdc80732cc9a3f84e46508f1ed1ec8cff 0
 9539f35bdc80732cc9a3f84e46508f1ed1ec8cff foo
--- a/tests/test-newbranch.out
+++ b/tests/test-newbranch.out
@@ -43,10 +43,10 @@ date:        Mon Jan 12 13:46:40 1970 +0
 summary:     initial
 
 foo                            5:5f8fb06e083e
-                               3:bf1bc2f45e83
+default                        3:bf1bc2f45e83
 bar                            2:67ec16bde7f1
 foo
-
+default
 bar
 % test for invalid branch cache
 rolling back last transaction
@@ -74,23 +74,23 @@ modify a branch
 
 
 4:4909a3732169
- features: unnamed
+ features: default
 4909a3732169c0c20011c4f4b8fdff4e3d89b23f 4
-bf1bc2f45e834c75404d0ddab57d53beab56e2f8 
+bf1bc2f45e834c75404d0ddab57d53beab56e2f8 default
 4909a3732169c0c20011c4f4b8fdff4e3d89b23f foo
 67ec16bde7f1575d523313b9bca000f6a6f12dca bar
 % test for different branch cache features
 branch cache: no features specified
 foo                            4:4909a3732169c0c20011c4f4b8fdff4e3d89b23f
-                               3:bf1bc2f45e834c75404d0ddab57d53beab56e2f8
+default                        3:bf1bc2f45e834c75404d0ddab57d53beab56e2f8
 bar                            2:67ec16bde7f1575d523313b9bca000f6a6f12dca
-branch cache: unknown features: dummy, foo, bar
+branch cache: missing features: default
 foo                            4:4909a3732169c0c20011c4f4b8fdff4e3d89b23f
-                               3:bf1bc2f45e834c75404d0ddab57d53beab56e2f8
+default                        3:bf1bc2f45e834c75404d0ddab57d53beab56e2f8
 bar                            2:67ec16bde7f1575d523313b9bca000f6a6f12dca
-branch cache: missing features: unnamed
+branch cache: missing features: default
 foo                            4:4909a3732169c0c20011c4f4b8fdff4e3d89b23f
-                               3:bf1bc2f45e834c75404d0ddab57d53beab56e2f8
+default                        3:bf1bc2f45e834c75404d0ddab57d53beab56e2f8
 bar                            2:67ec16bde7f1575d523313b9bca000f6a6f12dca
 % test old hg reading branch cache with feature list
 ValueError raised correctly, good.