changeset 3218:8d4855fd9d7b

merge: use new working context object in update
author Matt Mackall <mpm@selenic.com>
date Tue, 03 Oct 2006 01:21:46 -0500
parents 6d98149d70fe
children a184cd0c2db9
files mercurial/context.py mercurial/localrepo.py mercurial/merge.py
diffstat 3 files changed, 14 insertions(+), 32 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/context.py	Mon Oct 02 22:03:14 2006 -0500
+++ b/mercurial/context.py	Tue Oct 03 01:21:46 2006 -0500
@@ -342,7 +342,7 @@
     def _buildmanifest(self):
         """generate a manifest corresponding to the working directory"""
 
-        man = self._parents[0].manifest().coy()
+        man = self._parents[0].manifest().copy()
         copied = self._repo.dirstate.copies()
         modified, added, removed, deleted, unknown = self._status[:5]
         for i,l in (("a", added), ("m", modified), ("u", unknown)):
--- a/mercurial/localrepo.py	Mon Oct 02 22:03:14 2006 -0500
+++ b/mercurial/localrepo.py	Tue Oct 03 01:21:46 2006 -0500
@@ -321,6 +321,9 @@
     def changectx(self, changeid=None):
         return context.changectx(self, changeid)
 
+    def workingctx(self):
+        return context.workingctx(self)
+
     def parents(self, changeid=None):
         '''
         get list of changectxs for parents of changeid or working directory
--- a/mercurial/merge.py	Mon Oct 02 22:03:14 2006 -0500
+++ b/mercurial/merge.py	Tue Oct 03 01:21:46 2006 -0500
@@ -59,35 +59,17 @@
     os.unlink(c)
     return r
 
-def checkunknown(repo, m2, status):
+def checkunknown(repo, m2, wctx):
     """
     check for collisions between unknown files and files in m2
     """
-    modified, added, removed, deleted, unknown = status[:5]
-    for f in unknown:
+    for f in wctx.unknown():
         if f in m2:
             if repo.file(f).cmp(m2[f], repo.wread(f)):
                 raise util.Abort(_("'%s' already exists in the working"
                                    " dir and differs from remote") % f)
 
-def workingmanifest(repo, man, status):
-    """
-    Update manifest to correspond to the working directory
-    """
-
-    copied = repo.dirstate.copies()
-    modified, added, removed, deleted, unknown = status[:5]
-    for i,l in (("a", added), ("m", modified), ("u", unknown)):
-        for f in l:
-            man[f] = man.get(copied.get(f, f), nullid) + i
-            man.set(f, util.is_exec(repo.wjoin(f), man.execf(f)))
-
-    for f in deleted + removed:
-        del man[f]
-
-    return man
-
-def forgetremoved(m2, status):
+def forgetremoved(m2, wctx):
     """
     Forget removed files
 
@@ -98,10 +80,9 @@
     manifest.
     """
 
-    modified, added, removed, deleted, unknown = status[:5]
     action = []
 
-    for f in deleted + removed:
+    for f in wctx.deleted() + wctx.removed():
         if f not in m2:
             action.append((f, "f"))
 
@@ -332,7 +313,8 @@
 
     ### check phase
 
-    pl = repo.parents()
+    wc = repo.workingctx()
+    pl = wc.parents()
     if not overwrite and len(pl) > 1:
         raise util.Abort(_("outstanding uncommitted merges"))
 
@@ -351,13 +333,11 @@
         raise util.Abort(_("update spans branches, use 'hg merge' "
                            "or 'hg update -C' to lose changes"))
 
-    status = repo.status()
-    modified, added, removed, deleted, unknown = status[:5]
     if branchmerge and not forcemerge:
-        if modified or added or removed:
+        if wc.modified() or wc.added() or wc.removed():
             raise util.Abort(_("outstanding uncommitted changes"))
 
-    m1 = p1.manifest().copy()
+    m1 = wc.manifest().copy()
     m2 = p2.manifest().copy()
     ma = pa.manifest()
 
@@ -371,14 +351,13 @@
     action = []
     copy = {}
 
-    m1 = workingmanifest(repo, m1, status)
     filtermanifest(m1, partial)
     filtermanifest(m2, partial)
 
     if not force:
-        checkunknown(repo, m2, status)
+        checkunknown(repo, m2, wc)
     if not branchmerge:
-        action += forgetremoved(m2, status)
+        action += forgetremoved(m2, wc)
     if not (backwards or overwrite):
         copy = findcopies(repo, m1, m2, pa.rev())