Skip to content

Commit

Permalink
remove rename detection, add explicit changelog recording on merges
Browse files Browse the repository at this point in the history
  • Loading branch information
schacon committed Jun 1, 2009
1 parent 6610830 commit b8bc7b2
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 44 deletions.
52 changes: 13 additions & 39 deletions git_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ def export_commits(self):
self.save_map()

def push(self, remote_name):
self.fetch(remote_name) # get and convert objects if they already exist
self.ui.status(_("pushing to : %s\n") % remote_name)
self.export_commits()
self.update_remote_references(remote_name)
Expand Down Expand Up @@ -290,6 +291,11 @@ def is_octopus_part(ctx):
add_extras = True
extra_message += "extra : " + key + " : " + urllib.quote(value) + "\n"

# save file context listing on merge commit
if (len(parents) > 1):
add_extras = True
for filenm in ctx.files():
extra_message += "files : " + filenm + "\n"

if add_extras:
commit['message'] += "\n--HG--\n" + extra_message
Expand Down Expand Up @@ -546,7 +552,6 @@ def import_git_objects(self, remote_name=None, refs=None):
todo = []
done = set()
convert_list = {}
self.renames = {}

# get a list of all the head shas
if refs:
Expand Down Expand Up @@ -591,9 +596,6 @@ def import_git_objects(self, remote_name=None, refs=None):
commit = convert_list[csha]
if not self.map_hg_get(csha): # it's already here
self.import_git_commit(commit)
else:
# we need to get rename info for further upstream
self.pseudo_import_git_commit(commit)

self.update_hg_bookmarks(remote_name)

Expand Down Expand Up @@ -636,6 +638,7 @@ def extract_hg_metadata(self, message):
split = message.split("\n\n--HG--\n", 1)
renames = {}
extra = {}
files = []
branch = False
if len(split) == 2:
message, meta = split
Expand All @@ -651,39 +654,19 @@ def extract_hg_metadata(self, message):
renames[after] = before
if command == 'branch':
branch = data
if command == 'files':
files.append(data)
if command == 'extra':
before, after = data.split(" : ", 1)
extra[before] = urllib.unquote(after)
return (message, renames, branch, extra)

def pseudo_import_git_commit(self, commit):
(strip_message, hg_renames, hg_branch, extra) = self.extract_hg_metadata(commit.message)
cs = self.map_hg_get(commit.id)
p1 = nullid
p2 = nullid
if len(commit.parents) > 0:
sha = commit.parents[0]
p1 = self.map_hg_get(sha)
if len(commit.parents) > 1:
sha = commit.parents[1]
p2 = self.map_hg_get(sha)
if len(commit.parents) > 2:
# TODO : map extra parents to the extras file
pass
# saving rename info
if (not (p2 == nullid) or (p1 == nullid)):
self.renames[cs] = {}
else:
self.renames[cs] = self.renames[p1].copy()

self.renames[cs].update(hg_renames)
return (message, renames, branch, files, extra)

def import_git_commit(self, commit):
self.ui.debug(_("importing: %s\n") % commit.id)
# TODO : Do something less coarse-grained than try/except on the
# get_file call for removed files

(strip_message, hg_renames, hg_branch, extra) = self.extract_hg_metadata(commit.message)
(strip_message, hg_renames, hg_branch, force_files, extra) = self.extract_hg_metadata(commit.message)

# get a list of the changed, added, removed files
files = self.git.get_files_changed(commit)
Expand Down Expand Up @@ -757,20 +740,11 @@ def commit_octopus(p1, p2):
ctx = context.memctx(self.repo, (p1, p2), text, files, getfilectx,
author, date, extra)

node = self.repo.commitctx(ctx, pa)
node = self.repo.commitctx(ctx, pa, force_files)

# save changeset to mapping file
cs = hex(node)
self.map_set(commit.id, cs)

# saving rename info
if (not (p2 == nullid) or (p1 == nullid)):
self.renames[cs] = {}
else:
self.renames[cs] = self.renames[p1].copy()

self.renames[cs].update(hg_renames)

self.map_set(commit.id, cs)

def check_bookmarks(self):
if self.ui.config('extensions', 'hgext.bookmarks') is not None:
Expand Down
13 changes: 8 additions & 5 deletions hgrepo.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

class hgrepo(localrepo.localrepository):

def commitctx(self, wctx, ancestor):
def commitctx(self, wctx, ancestor, force_files = False):

tr = None
valid = 0 # don't save the dirstate if this isn't set
Expand Down Expand Up @@ -64,9 +64,6 @@ def commitctx(self, wctx, ancestor):

except (OSError, IOError):
remove.append(f)

print 'CHANGED'
print changed

updated, added = [], []
for f in sorted(changed):
Expand Down Expand Up @@ -99,8 +96,14 @@ def commitctx(self, wctx, ancestor):
raise util.Abort(_("empty commit message"))
text = '\n'.join(lines)

file_list = []
if len(force_files) > 0:
file_list = force_files
else:
file_list = changed + removed

self.changelog.delayupdate()
n = self.changelog.add(mn, changed + removed, text, trp, p1, p2,
n = self.changelog.add(mn, file_list, text, trp, p1, p2,
user, wctx.date(), extra)
p = lambda: self.changelog.writepending() and self.root or ""
self.hook('pretxncommit', throw=True, node=hex(n), parent1=xp1,
Expand Down

0 comments on commit b8bc7b2

Please sign in to comment.