Merge with main
authorBrendan Cully <brendan@kublai.com>
Thu, 05 Jul 2007 14:32:18 -0700
changeset 4838 61343b40a141
parent 4837 4cdbaa885d8a (current diff)
parent 4821 f48290864625 (diff)
child 4839 e20e40f67f0e
Merge with main
tests/test-issue612
tests/test-issue619
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hgext/interhg.py	Thu Jul 05 14:32:18 2007 -0700
@@ -0,0 +1,64 @@
+# interhg.py - interhg
+#
+# Copyright 2007 OHASHI Hideya <ohachige@gmail.com>
+#
+# This software may be used and distributed according to the terms
+# of the GNU General Public License, incorporated herein by reference.
+#
+# The `interhg' Mercurial extension allows you to change changelog and
+# summary text just like InterWiki way.
+#
+# To enable this extension:
+#
+#   [extensions]
+#   interhg =
+#
+# This is an example to link to a bug tracking system.
+#
+#   [interhg]
+#   pat1 = s/issue(\d+)/ <a href="http:\/\/bts\/issue\1">issue\1<\/a> /
+#
+# You can add patterns to use pat2, pat3, ...
+# For exapmle.
+#
+#   pat2 = s/(^|\s)#(\d+)\b/ <b>#\2<\/b> /
+
+import re
+from mercurial.hgweb import hgweb_mod
+from mercurial import templater
+
+orig_escape = templater.common_filters["escape"]
+
+interhg_table = []
+
+def interhg_escape(x):
+    escstr = orig_escape(x)
+    for pat in interhg_table:
+        regexp = pat[0]
+        format = pat[1]
+        escstr = regexp.sub(format, escstr)
+    return escstr
+
+templater.common_filters["escape"] = interhg_escape
+
+orig_refresh = hgweb_mod.hgweb.refresh
+
+def interhg_refresh(self):
+    interhg_table[:] = []
+    num = 1
+    while True:
+        key = 'pat%d' % num
+        pat = self.config('interhg', key)
+        if pat == None:
+            break
+        pat = pat[2:-1]
+        span = re.search(r'[^\\]/', pat).span()
+        regexp = pat[:span[0] + 1]
+        format = pat[span[1]:]
+        format = re.sub(r'\\/', '/', format)
+        regexp = re.compile(regexp)
+        interhg_table.append((regexp, format))
+        num += 1
+    return orig_refresh(self)
+
+hgweb_mod.hgweb.refresh = interhg_refresh
--- a/mercurial/commands.py	Thu Jul 05 14:31:13 2007 -0700
+++ b/mercurial/commands.py	Thu Jul 05 14:32:18 2007 -0700
@@ -3109,6 +3109,8 @@
     "version": (version_, [], _('hg version')),
 }
 
+extensions.commandtable = table
+
 norepo = ("clone init version help debugancestor debugcomplete debugdata"
           " debugindex debugindexdot debugdate debuginstall")
 optionalrepo = ("paths serve showconfig")
--- a/mercurial/context.py	Thu Jul 05 14:31:13 2007 -0700
+++ b/mercurial/context.py	Thu Jul 05 14:32:18 2007 -0700
@@ -40,6 +40,9 @@
         except AttributeError:
             return False
 
+    def __ne__(self, other):
+        return not (self == other)
+
     def __nonzero__(self):
         return self._rev != nullrev
 
@@ -185,6 +188,9 @@
         except AttributeError:
             return False
 
+    def __ne__(self, other):
+        return not (self == other)
+
     def filectx(self, fileid):
         '''opens an arbitrary revision of the file without
         opening a new filelog'''
--- a/mercurial/extensions.py	Thu Jul 05 14:31:13 2007 -0700
+++ b/mercurial/extensions.py	Thu Jul 05 14:32:18 2007 -0700
@@ -6,10 +6,12 @@
 # of the GNU General Public License, incorporated herein by reference.
 
 import imp, os
-import commands, hg, util, sys
+import util, sys
 from i18n import _
 
 _extensions = {}
+commandtable = {}
+setuphooks = []
 
 def find(name):
     '''return module with given extension name'''
@@ -54,13 +56,13 @@
         uisetup(ui)
     reposetup = getattr(mod, 'reposetup', None)
     if reposetup:
-        hg.repo_setup_hooks.append(reposetup)
+        setuphooks.append(reposetup)
     cmdtable = getattr(mod, 'cmdtable', {})
-    overrides = [cmd for cmd in cmdtable if cmd in commands.table]
+    overrides = [cmd for cmd in cmdtable if cmd in commandtable]
     if overrides:
         ui.warn(_("extension '%s' overrides commands: %s\n")
                 % (name, " ".join(overrides)))
-    commands.table.update(cmdtable)
+    commandtable.update(cmdtable)
 
 def loadall(ui):
     result = ui.configitems("extensions")
--- a/mercurial/hg.py	Thu Jul 05 14:31:13 2007 -0700
+++ b/mercurial/hg.py	Thu Jul 05 14:32:18 2007 -0700
@@ -10,7 +10,7 @@
 from repo import *
 from i18n import _
 import localrepo, bundlerepo, httprepo, sshrepo, statichttprepo
-import errno, lock, os, shutil, util, cmdutil
+import errno, lock, os, shutil, util, cmdutil, extensions
 import merge as _merge
 import verify as _verify
 
@@ -50,13 +50,11 @@
             return False
     return repo.local()
 
-repo_setup_hooks = []
-
 def repository(ui, path='', create=False):
     """return a repository object for the specified path"""
     repo = _lookup(path).instance(ui, path, create)
     ui = getattr(repo, "ui", ui)
-    for hook in repo_setup_hooks:
+    for hook in extensions.setuphooks:
         hook(ui, repo)
     return repo
 
--- a/mercurial/merge.py	Thu Jul 05 14:31:13 2007 -0700
+++ b/mercurial/merge.py	Thu Jul 05 14:32:18 2007 -0700
@@ -478,6 +478,9 @@
                     repo.dirstate.forget([f])
         elif m == "d": # directory rename
             f2, fd, flag = a[2:]
+            if not f2 and f not in repo.dirstate:
+                # untracked file moved
+                continue
             if branchmerge:
                 repo.dirstate.update([fd], 'a')
                 if f:
@@ -523,7 +526,7 @@
         raise util.Abort(_("outstanding uncommitted merges"))
     if pa == p1 or pa == p2: # is there a linear path from p1 to p2?
         if branchmerge:
-            if p1.branch() != p2.branch():
+            if p1.branch() != p2.branch() and pa != p2:
                 fastforward = True
             else:
                 raise util.Abort(_("there is nothing to merge, just use "
--- a/setup.py	Thu Jul 05 14:31:13 2007 -0700
+++ b/setup.py	Thu Jul 05 14:32:18 2007 -0700
@@ -2,8 +2,8 @@
 #
 # This is the mercurial setup script.
 #
-# './setup.py install', or
-# './setup.py --help' for more options
+# 'python setup.py install', or
+# 'python setup.py --help' for more options
 
 import sys
 if not hasattr(sys, 'version_info') or sys.version_info < (2, 3, 0, 'final'):
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/test-issue612	Thu Jul 05 14:32:18 2007 -0700
@@ -0,0 +1,24 @@
+#!/bin/sh
+
+mkdir t
+cd t
+
+hg init
+mkdir src
+echo a > src/a.c
+hg ci -Ama -d "10000000 0"
+
+hg mv src source
+hg ci -Ammove -d "1000000 0"
+
+hg co -C 0
+echo new > src/a.c
+echo compiled > src/a.o
+hg ci -mupdate -d "1000000 0"
+
+hg st
+
+hg merge
+
+hg st
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/test-issue612.out	Thu Jul 05 14:32:18 2007 -0700
@@ -0,0 +1,11 @@
+adding src/a.c
+copying src/a.c to source/a.c
+removing src/a.c
+1 files updated, 0 files merged, 1 files removed, 0 files unresolved
+? src/a.o
+merging src/a.c and source/a.c
+1 files updated, 1 files merged, 0 files removed, 0 files unresolved
+(branch merge, don't forget to commit)
+M source/a.c
+R src/a.c
+? source/a.o
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/test-issue619	Thu Jul 05 14:32:18 2007 -0700
@@ -0,0 +1,20 @@
+#!/bin/sh
+
+mkdir t
+cd t
+hg init
+echo a > a
+hg ci -Ama -d '1000000000 0'
+echo b > b
+hg branch b
+hg ci -Amb -d '1000000000 0'
+hg co -C 0
+
+echo fast-forward
+hg merge b
+hg ci -Ammerge -d '1000000000 0'
+
+echo bogus fast-forward should fail
+hg merge b
+
+echo done
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/test-issue619.out	Thu Jul 05 14:32:18 2007 -0700
@@ -0,0 +1,10 @@
+adding a
+marked working directory as branch b
+adding b
+0 files updated, 0 files merged, 1 files removed, 0 files unresolved
+fast-forward
+1 files updated, 0 files merged, 0 files removed, 0 files unresolved
+(branch merge, don't forget to commit)
+bogus fast-forward should fail
+abort: there is nothing to merge, just use 'hg update' or look at 'hg heads'
+done