# HG changeset patch # User Brendan Cully # Date 1183671138 25200 # Node ID 61343b40a1418bcc25c86f42e903a0cf53c0bf1d # Parent 4cdbaa885d8a97a247c6d520b799ec792a1075bd# Parent f48290864625d7de522ad990230e1d7cc437c20a Merge with main diff --git a/hgext/interhg.py b/hgext/interhg.py new file mode 100644 --- /dev/null +++ b/hgext/interhg.py @@ -0,0 +1,64 @@ +# interhg.py - interhg +# +# Copyright 2007 OHASHI Hideya +# +# 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+)/ issue\1<\/a> / +# +# You can add patterns to use pat2, pat3, ... +# For exapmle. +# +# pat2 = s/(^|\s)#(\d+)\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 diff --git a/mercurial/commands.py b/mercurial/commands.py --- a/mercurial/commands.py +++ b/mercurial/commands.py @@ -3109,6 +3109,8 @@ table = { "version": (version_, [], _('hg version')), } +extensions.commandtable = table + norepo = ("clone init version help debugancestor debugcomplete debugdata" " debugindex debugindexdot debugdate debuginstall") optionalrepo = ("paths serve showconfig") diff --git a/mercurial/context.py b/mercurial/context.py --- a/mercurial/context.py +++ b/mercurial/context.py @@ -40,6 +40,9 @@ class changectx(object): except AttributeError: return False + def __ne__(self, other): + return not (self == other) + def __nonzero__(self): return self._rev != nullrev @@ -185,6 +188,9 @@ class filectx(object): 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''' diff --git a/mercurial/extensions.py b/mercurial/extensions.py --- a/mercurial/extensions.py +++ b/mercurial/extensions.py @@ -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 @@ def load(ui, name, path): 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") diff --git a/mercurial/hg.py b/mercurial/hg.py --- a/mercurial/hg.py +++ b/mercurial/hg.py @@ -10,7 +10,7 @@ from node import * 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 @@ def islocal(repo): 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 diff --git a/mercurial/merge.py b/mercurial/merge.py --- a/mercurial/merge.py +++ b/mercurial/merge.py @@ -478,6 +478,9 @@ def recordupdates(repo, action, branchme 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 @@ def update(repo, node, branchmerge, forc 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 " diff --git a/setup.py b/setup.py --- a/setup.py +++ b/setup.py @@ -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'): diff --git a/tests/test-issue612 b/tests/test-issue612 new file mode 100755 --- /dev/null +++ b/tests/test-issue612 @@ -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 + diff --git a/tests/test-issue612.out b/tests/test-issue612.out new file mode 100644 --- /dev/null +++ b/tests/test-issue612.out @@ -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 diff --git a/tests/test-issue619 b/tests/test-issue619 new file mode 100755 --- /dev/null +++ b/tests/test-issue619 @@ -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 diff --git a/tests/test-issue619.out b/tests/test-issue619.out new file mode 100644 --- /dev/null +++ b/tests/test-issue619.out @@ -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