changeset 4676:0f6e2b37512d

Merge with Eric Hopper
author Matt Mackall <mpm@selenic.com>
date Thu, 21 Jun 2007 18:05:14 -0500
parents 723e0ddb6ada (diff) 6858a7477a5e (current diff)
children de8ec7e1753a
files mercurial/commands.py tests/test-branches
diffstat 9 files changed, 81 insertions(+), 28 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/cmdutil.py	Thu Jun 21 10:40:09 2007 -0700
+++ b/mercurial/cmdutil.py	Thu Jun 21 18:05:14 2007 -0500
@@ -262,11 +262,9 @@
         os.chdir(cwd)
 
     # read the local repository .hgrc into a local ui object
-    # this will trigger its extensions to load
-    path = earlygetopt(["-R", "--repository", "--repo"], args)
+    path = findrepo() or ""
     if not path:
-        path = findrepo() or ""
-    lui = ui
+        lui = ui
     if path:
         try:
             lui = commands.ui.ui(parentui=ui)
@@ -274,6 +272,13 @@
         except IOError:
             pass
 
+    # now we can expand paths, even ones in .hg/hgrc
+    rpath = earlygetopt(["-R", "--repository", "--repo"], args)
+    if rpath:
+        path = lui.expandpath(rpath)
+        lui = commands.ui.ui(parentui=ui)
+        lui.readconfig(os.path.join(path, ".hg", "hgrc"))
+
     extensions.loadall(lui)
     # check for fallback encoding
     fallback = lui.config('ui', 'fallbackencoding')
@@ -316,7 +321,7 @@
         try:
             repo = hg.repository(ui, path=path)
             ui = repo.ui
-            if not repo.local() and cmd not in commands.remoterepo.split():
+            if not repo.local():
                 raise util.Abort(_("repository '%s' is not local") % path)
         except hg.RepoError:
             if cmd not in commands.optionalrepo.split():
--- a/mercurial/commands.py	Thu Jun 21 10:40:09 2007 -0700
+++ b/mercurial/commands.py	Thu Jun 21 18:05:14 2007 -0500
@@ -1445,10 +1445,13 @@
             else:
                 ui.write("%s\n" % first)
 
-def identify(ui, repo, rev=None, num=None, id=None, branch=None, tags=None):
+def identify(ui, repo, source=None,
+             rev=None, num=None, id=None, branch=None, tags=None):
     """identify the working copy or specified revision
 
-    With no argument, print a summary of the current state of the repo.
+    With no revision, print a summary of the current state of the repo.
+
+    With a path, do a lookup in another repository.
 
     This summary identifies the repository state using one or two parent
     hash identifiers, followed by a "+" if there are uncommitted changes
@@ -1460,13 +1463,17 @@
     default = not (num or id or branch or tags)
     output = []
 
-    if not repo.local():
+    if source:
+        source, revs = cmdutil.parseurl(ui.expandpath(source), [])
+        srepo = hg.repository(ui, source)
+        if not rev and revs:
+            rev = revs[0]
         if not rev:
             rev = "tip"
         if num or branch or tags:
             raise util.Abort(
                 "can't query remote revision number, branch, or tags")
-        output = [hexfunc(repo.lookup(rev))]
+        output = [hexfunc(srepo.lookup(rev))]
     elif not rev:
         ctx = repo.workingctx()
         parents = ctx.parents()
@@ -1486,7 +1493,7 @@
         if num:
             output.append(str(ctx.rev()))
 
-    if repo.local() and default and not ui.quiet:
+    if not source and default and not ui.quiet:
         b = util.tolocal(ctx.branch())
         if b != 'default':
             output.append("(%s)" % b)
@@ -2438,6 +2445,7 @@
 
     class service:
         def init(self):
+            util.set_signal_handler()
             try:
                 self.httpd = hgweb.server.create_server(parentui, repo)
             except socket.error, inst:
@@ -2872,7 +2880,7 @@
           ('i', 'id', None, _('show global revision id')),
           ('b', 'branch', None, _('show branch')),
           ('t', 'tags', None, _('show tags'))],
-         _('hg identify [-nibt] [-r REV]')),
+         _('hg identify [-nibt] [-r REV] [SOURCE]')),
     "import|patch":
         (import_,
          [('p', 'strip', 1,
@@ -3079,7 +3087,6 @@
 norepo = ("clone init version help debugancestor debugcomplete debugdata"
           " debugindex debugindexdot debugdate debuginstall")
 optionalrepo = ("paths serve showconfig")
-remoterepo = ("identify")
 
 def dispatch(args):
     try:
--- a/mercurial/hgweb/hgweb_mod.py	Thu Jun 21 10:40:09 2007 -0700
+++ b/mercurial/hgweb/hgweb_mod.py	Thu Jun 21 18:05:14 2007 -0500
@@ -619,11 +619,11 @@
         'zip': ('application/zip', 'zip', '.zip', None),
         }
 
-    def archive(self, req, id, type_):
+    def archive(self, req, key, type_):
         reponame = re.sub(r"\W+", "-", os.path.basename(self.reponame))
-        cnode = self.repo.lookup(id)
-        arch_version = id
-        if cnode == id or id == 'tip':
+        cnode = self.repo.lookup(key)
+        arch_version = key
+        if cnode == key or key == 'tip':
             arch_version = short(cnode)
         name = "%s-%s" % (reponame, arch_version)
         mimetype, artype, extension, encoding = self.archive_specs[type_]
--- a/mercurial/merge.py	Thu Jun 21 10:40:09 2007 -0700
+++ b/mercurial/merge.py	Thu Jun 21 18:05:14 2007 -0500
@@ -155,11 +155,15 @@
 
     copy = {}
     fullcopy = {}
+    diverge = {}
 
     def checkcopies(c, man):
         '''check possible copies for filectx c'''
         for of in findold(c):
+            fullcopy[c.path()] = of # remember for dir rename detection
             if of not in man: # original file not in other manifest?
+                if of in ma:
+                    diverge.setdefault(of, []).append(c.path())
                 continue
             c2 = ctx(of, man[of])
             ca = c.ancestor(c2)
@@ -167,17 +171,16 @@
                 continue
             # named changed on only one side?
             if ca.path() == c.path() or ca.path() == c2.path():
-                fullcopy[c.path()] = of # remember for dir rename detection
                 if c == ca or c2 == ca: # no merge needed, ignore copy
                     continue
                 copy[c.path()] = of
 
     if not repo.ui.configbool("merge", "followcopies", True):
-        return {}
+        return {}, {}
 
     # avoid silly behavior for update from empty dir
     if not m1 or not m2 or not ma:
-        return {}
+        return {}, {}
 
     u1 = nonoverlap(m1, m2, ma)
     u2 = nonoverlap(m2, m1, ma)
@@ -188,8 +191,16 @@
     for f in u2:
         checkcopies(ctx(f, m2[f]), m1)
 
+    d2 = {}
+    for of, fl in diverge.items():
+        for f in fl:
+            fo = list(fl)
+            fo.remove(f)
+            d2[f] = (of, fo)
+    #diverge = d2
+
     if not fullcopy or not repo.ui.configbool("merge", "followdirs", True):
-        return copy
+        return copy, diverge
 
     # generate a directory move map
     d1, d2 = dirs(m1), dirs(m2)
@@ -223,7 +234,7 @@
     del d1, d2, invalid
 
     if not dirmove:
-        return copy
+        return copy, diverge
 
     # check unaccounted nonoverlapping files against directory moves
     for f in u1 + u2:
@@ -234,7 +245,7 @@
                     copy[f] = dirmove[d] + f[len(d):]
                     break
 
-    return copy
+    return copy, diverge
 
 def manifestmerge(repo, p1, p2, pa, overwrite, partial):
     """
@@ -254,6 +265,7 @@
     backwards = (pa == p2)
     action = []
     copy = {}
+    diverge = {}
 
     def fmerge(f, f2=None, fa=None):
         """merge flags"""
@@ -273,7 +285,11 @@
         action.append((f, m) + args)
 
     if not (backwards or overwrite):
-        copy = findcopies(repo, m1, m2, ma, pa.rev())
+        copy, diverge = findcopies(repo, m1, m2, ma, pa.rev())
+
+    for of, fl in diverge.items():
+        act("divergent renames", "dr", of, fl)
+
     copied = dict.fromkeys(copy.values())
 
     # Compare manifests
@@ -410,6 +426,11 @@
                 t = mctx.filectx(f2).data()
                 repo.wwrite(fd, t, flags)
             updated += 1
+        elif m == "dr": # divergent renames
+            fl = a[2]
+            repo.ui.warn("warning: detected divergent renames of %s to:\n" % f)
+            for nf in fl:
+                repo.ui.warn(" %s\n" % nf)
         elif m == "e": # exec
             flags = a[2]
             util.set_exec(repo.wjoin(f), flags)
--- a/mercurial/util.py	Thu Jun 21 10:40:09 2007 -0700
+++ b/mercurial/util.py	Thu Jun 21 18:05:14 2007 -0500
@@ -1100,6 +1100,9 @@
                 return p_name
         return default
 
+    def set_signal_handler():
+        pass
+
 def find_exe(name, default=None):
     '''find path of an executable.
     if name contains a path component, return it as is.  otherwise,
@@ -1152,9 +1155,6 @@
     this function is used to hide the details of COW semantics and
     remote file access from higher level code.
     """
-    p = base
-    audit_p = audit
-
     def mktempcopy(name, emptyok=False):
         d, fn = os.path.split(name)
         fd, temp = tempfile.mkstemp(prefix='.%s-' % fn, dir=d)
@@ -1209,9 +1209,9 @@
                 posixfile.close(self)
 
     def o(path, mode="r", text=False, atomictemp=False):
-        if audit_p:
+        if audit:
             audit_path(path)
-        f = os.path.join(p, path)
+        f = os.path.join(base, path)
 
         if not text:
             mode += "b" # for that other OS
--- a/mercurial/util_win32.py	Thu Jun 21 10:40:09 2007 -0700
+++ b/mercurial/util_win32.py	Thu Jun 21 18:05:14 2007 -0500
@@ -299,3 +299,12 @@
             raise WinIOError(err)
 
 getuser_fallback = win32api.GetUserName
+
+def set_signal_handler():
+    """Register a termination handler for console events including
+    CTRL+C. python signal handlers do not work well with socket
+    operations.
+    """
+    def handler(event):
+        win32process.ExitProcess(1)
+    win32api.SetConsoleCtrlHandler(handler)
--- a/tests/test-bundle-r.out	Thu Jun 21 10:40:09 2007 -0700
+++ b/tests/test-bundle-r.out	Thu Jun 21 18:05:14 2007 -0500
@@ -197,6 +197,9 @@
 crosschecking files in changesets and manifests
 checking files
 3 files, 7 changesets, 6 total revisions
+warning: detected divergent renames of afile to:
+ anotherfile
+ adifferentfile
 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
 (branch merge, don't forget to commit)
 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
--- a/tests/test-rename-merge1.out	Thu Jun 21 10:40:09 2007 -0700
+++ b/tests/test-rename-merge1.out	Thu Jun 21 18:05:14 2007 -0500
@@ -4,12 +4,16 @@
 resolving manifests
  overwrite None partial False
  ancestor af1939970a1c local f26ec4fc3fa3+ remote 8e765a822af2
+ a2: divergent renames -> dr
  a: remote moved to b -> m
  b2: remote created -> g
 merging a and b
 my a@f26ec4fc3fa3+ other b@8e765a822af2 ancestor a@af1939970a1c
 copying a to b
 removing a
+warning: detected divergent renames of a2 to:
+ c2
+ b2
 getting b2
 1 files updated, 1 files merged, 0 files removed, 0 files unresolved
 (branch merge, don't forget to commit)
--- a/tests/test-rename-merge2.out	Thu Jun 21 10:40:09 2007 -0700
+++ b/tests/test-rename-merge2.out	Thu Jun 21 18:05:14 2007 -0500
@@ -173,8 +173,12 @@
 resolving manifests
  overwrite None partial False
  ancestor 924404dff337 local ecf3cb2a4219+ remote e6abcc1a30c2
+ a: divergent renames -> dr
  rev: versions differ -> m
  c: remote created -> g
+warning: detected divergent renames of a to:
+ b
+ c
 getting c
 merging rev
 my rev@ecf3cb2a4219+ other rev@e6abcc1a30c2 ancestor rev@924404dff337