Add branch support to commit
authorMatt Mackall <mpm@selenic.com>
Tue, 17 Oct 2006 18:32:00 -0500
changeset 3419 d0459ec1455d
parent 3418 5436c8fe0ff5
child 3420 2576b6731524
Add branch support to commit
mercurial/localrepo.py
--- a/mercurial/localrepo.py	Tue Oct 17 18:31:56 2006 -0500
+++ b/mercurial/localrepo.py	Tue Oct 17 18:32:00 2006 -0500
@@ -611,7 +611,14 @@
         m1 = self.manifest.read(c1[0]).copy()
         m2 = self.manifest.read(c2[0])
 
-        if not commit and not remove and not force and p2 == nullid:
+        try:
+            branchname = self.opener("branch").read().rstrip()
+        except IOError:
+            branchname = ""
+        oldname = c1[5].get("branch", "")
+
+        if not commit and not remove and not force and p2 == nullid and \
+               branchname == oldname:
             self.ui.status(_("nothing changed\n"))
             return None
 
@@ -676,7 +683,11 @@
         if not lines:
             return None
         text = '\n'.join(lines)
-        n = self.changelog.add(mn, changed + remove, text, tr, p1, p2, user, date)
+        extra = {}
+        if branchname:
+            extra["branch"] = branchname
+        n = self.changelog.add(mn, changed + remove, text, tr, p1, p2,
+                               user, date, extra)
         self.hook('pretxncommit', throw=True, node=hex(n), parent1=xp1,
                   parent2=xp2)
         tr.close()